Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Programatically delete Photoshop Temp##### files

New Here ,
Mar 07, 2009 Mar 07, 2009
XP Pro
CS3
1GB Ram
Scripting with JavaScipt

We run photoshop doing batch processes all week long. Is there anyway to include in the javascript batch process a command to delete the temp file that gets built up. I realize they are normally deleted upon proper program termination but that doesn't always happen.
Since the name appears somewhat with random numbers I am not sure how I could point directly at that, the constant appears to be "Photoshop Temp" but there is also the numbers at the end of that file name to consider.

or for another consideration (secondary).

Can I put at the end of the batch command a line of code to close Photoshop? If so what would that be?

Thank you,

Jeff
TOPICS
Actions and scripting
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 07, 2009 Mar 07, 2009
You can use the getFiles() function of a Folder object to get access to all the files in a specific folder. If you know that the temp files in question begin with a certain string you can match their names for that string, and delete them if you so wish.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mar 08, 2009 Mar 08, 2009
Are you talking about Scratch files?

Those should now be deleted even if the application crashes. (they're unlinked as soon as they're created)

They will certainly be deleted when Photoshop launches again.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2009 Mar 09, 2009
Yes, I am talking about scratch files.

Two parts...
If the Photoshop application is run all week and we process 1GB of files through there it is going to make a huge scratch file correct? That is also why am curious if I can put a line of code at the end of the script to terminate Photoshop which will delete the scratch file.

As far as workflow goes in our environment the best way is to take the recommendation of "try67" and use the getFiles() function of the currently logged in user and delete that scratch file if Photoshop will allow me to do that while the Photoshop application is still running.

Concerning the automatic deletion of scratch files...
I will take a closer look. I just had to go in delete 4 different scratch files on the day I originally posted this thread (3/7/2009).
I am going to confirm that the installation is up to date.

Another question which you will probably be able to answer right away. If I (user "A") am bumped out due to an application crash and someone else (user "B") logs in will it still delete the scratch file upon Photoshop launch?

Thank you very much for your time in reviewing my question and replying.
Jeff
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 09, 2009 Mar 09, 2009
Photoshop has not always done a good job with cleaning up these temp files,
especially if PS crashes (which is not an uncommon for me).

The simplest thing is to try do delete all of them when PS starts up. The
remove() call will fail for the current temp file(s), but you do have to know
where they're located to do the getFiles() call.

And if you want to shutdown, photoshop at the end of your script, do this:
photoshop.quit();


For a more elaborate solution, you could send bit of script to Bridge to
shutdown PS, remove all of the temp files and restart PS. I've written several
fault-tolerant scripts that would restart PS multiple times when processing
thousands of images over the course 12-48 hours, so this technique does work.


> If I (user "A") am bumped out due to an application crash and someone else (user "B") logs in will it still delete the scratch file upon Photoshop launch?

From what I have seen in the past, the temp files are deleted as a part of
normal PS shutdown, not during startup. I've had several temp files of different
ages laying around long after they were needed.

-X
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2009 Mar 09, 2009
After viewing everything so far the solution to shut down PS to remove temp files and restart PS would be the best workflow option for us.

Since on windows I am thinking that I should have written this in VB Script instead of javascript. But I did write it in javascript due to the possibiity of switching to an apple machine later on.
🙂 Hind sight.

I guess really it would be best to re-write this in VB Script to also include the shutting down of PS - deleting the temp files and restarting PS.
I will have to do some research on this. If anyone has any input on the use of VB Script to accomplish the above that would be awesome.

Does anyone see a possible solution with the current JavaScript I use to accomplish that on Windows?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mar 09, 2009 Mar 09, 2009
LATEST
Again, with recent versions of Photoshop - the scratch files should not hang around. And Photoshop does delete them when quitting, and does a double check to delete any that might hang around when Photoshop launches again.

I'm not sure about cross account cleanup -- file permissions might get in the way.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines