Skip to main content
Participating Frequently
July 28, 2010
Question

Need a script for time tracking

  • July 28, 2010
  • 2 replies
  • 2089 views

I need to have a total time taken  for each file( time  differences between open file  and save file. Is there any way to display that list?

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
July 29, 2010

cakunder wrote:

I need to have a total time taken  for each file( time  differences between open file  and save file. Is there any way to display that list?

I think the you may use save more then once when you edit a document. So  I think the time difference you want is between Open and Close of your documents.  I think you may be able to do what you want by enabling  the script event manager and setting up two events to run a couple of scripts. The Open event would record the start date and time in the documents meta-data.  The close event script would retrieve the start date and time  from the documents meta-data and subtract that from the current date and time.  Then  record the close date and time along with the time interval calculated in the files meta data and re save the document or log all into an edit log you have created on your system to record all edit sessions durations. What I'm not sure of is whether the document is in Photoshop when the events scripts get control I would guess the document would be there.

JJMack
JJMack
Community Expert
Community Expert
July 30, 2010

JJMack wrote:

What I'm not sure of is whether the document is in Photoshop when the events scripts get control I would guess the document would be there.

Yes I was not sure and my guess was wrong. The Event scripts get control after the event take place.  So the Document is in Photoshop after the Open event. However after a Close event when the script gets control the document is no longer in Photoshop. During the close event if there  is a current document  it is not the document you want to log. So associating such a script with a close event would be a mistake for if there is an active document it would be a different document then the one closed the wrong document.

So the only way I was able to do what you wanted was to write a script and associate it with three Photoshop events. New Document Event, Open Document Event and Save Document Event.  The Save Event catches two Photoshop file menu items "Save" and "Save As...".  Note the Photoshop file menu item "Save for Web & Devices.." does not trigger the Save event.  The Photoshop Script I wrote also turned the Save event into a "File" event for it re saves the Document to clean out the recorded start time in the meta-data and then closed the Photoshop document to end the current Photoshop session on that document.  During the Save event the script log the session in a session log in the folder the script was run from and also alerts the user with a message before the document is closed.

There is a problem also if you duplicate a document there is no event for this which is good for there should be a start time in the document being duplicated meta-data so if it triggered the script it would likely be saved and closed. As it stands now a duplicated document would have the original document edit session start time.

IMO some additional problem exists  with Photoshop Event Manager for Actions do not seem to trigger Photoshop Events.  I tested some actions that  Open New documents  and ones that open old Document and Duplicated a document  none of the actions trigged a new or open event. I would assume then an action the did a save or save as would not trigger a save event.

So I don't think there is a foolproof way of doing what you want to do.  If you have complete control over what is installed into Photoshop you may stand a chance.

I'm just a hacker when it comes down to Photoshop scripts.  Adobe's "Script Events Manager.jsx" is beyond my Javascript and Photoshop Scripting knowledge.  Perhaps someone with a good working knowledge of Javascript and Photoshop scripting could find a way to have Action Steps to trigger Script Events. Or it  might require a change in Photoshop's Action feature I do not know.... 

JJMack
JJMack
Community Expert
Community Expert
July 31, 2010

Does anyone know if an action step like make new document should trigger the Script Events Manager's  "New Document:" event??? 

JJMack
try67
Community Expert
Community Expert
July 28, 2010

Use the Date object in JavaScript.

At the start of the script place this line:

var startTime = new Date().getTime();

And at the end place this one:

var endTime = new Date().getTime();

The difference between endTime and startTime is the time (in ms) it took your script to run.