Skip to main content
JavierAroche
Inspiring
December 6, 2016
Answered

Delete smart object Photoshop files in TemporaryItems folder

  • December 6, 2016
  • 2 replies
  • 4114 views

When you open a smart object in a Photoshop document, a new PSB file is created in your TemporaryItems folder. If you open a lot of smart objects in that document, your hard drive could eventually run out of space.

I know that closing the document will delete these temporary Photoshop files. But, is it possible to delete these temp files, through ExtendScript, without closing the document?

Unfortunately the purge method doesn't clear these files.

app.purge(PurgeTarget.ALLCACHES)

Any ideas?

Thanks!

PS. I'm running Photoshop 2015.0

This topic has been closed for replies.
Correct answer Jarda Bereza

I am using code like this:

var deleteFile = new File("C://yourPath//something//something.psb");

     deleteFile.remove();

     deleteFile.close();

2 replies

Jarda Bereza
Jarda BerezaCorrect answer
Inspiring
December 6, 2016

I am using code like this:

var deleteFile = new File("C://yourPath//something//something.psb");

     deleteFile.remove();

     deleteFile.close();

JavierAroche
Inspiring
December 7, 2016

Yes, that seems to be the best solution since Photoshop doesn't have a native way of doing it.

Thanks guys!

JJMack
Community Expert
December 6, 2016

When you Close  the document that you opened a smart Object layers object from. Photoshop should delete the temp work PSB file as you wrote. When you open the Object Photoshop creates that temp work PSB when you  update the work document close and save it. Photoshop Updated the smart object layer object using the temp file.  Photoshop does not delete that file at that point In case you open and edit the object again. Photoshop will reuse that temp file for you to work on the object again.  When you close the File with the Smart Object layer Photoshop should delete the temp PSB file as you know. If you delete that file before you close the document with the smart object before Photoshop does and the edit the object again you may mess up Photoshop for it had created that file and want to reuse it. If you do not reopen it Photoshop will still try to delete the work file when you  What happens if you deleted it.close the document with the smart object.

If I were you I would open a smart object update the work document close and save it. So the smart object gets updated. Delete the work file manually if you can Photoshop may be holding a lock on it.  If you can delete it.  Open the smart object again  see if Photoshop is OK.

JJMack
JavierAroche
Inspiring
December 6, 2016

Hey JJMack​, thanks for the fast reply!

I understand the purpose of the temporary files. It speeds things up if you need to reopen the smart object. However, I need to delete them because I'm opening a lot of smart objects in the same document.

Deleting the PSB file manually doesn't break anything, and the file isn't locked either. If I manually delete it from the temp folder, Photoshop will simply create a new one when you open the smart object again.

I can manually delete the files with a system command, but I was wondering if Photoshop had a function in its API to perform this action.

JJMack
Community Expert
December 6, 2016

The only thing I could think of is a close event. However events are triggered after the fact not before, Therefore the the document would no longer be open in  Photoshop open documents array.  I would not know how you would be able to find the backing file was one of those temp work document,

JJMack