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

Clear Scratch Disks When Running Script

Community Beginner ,
Jan 02, 2020 Jan 02, 2020

Copy link to clipboard

Copied

Hi, I'm running a script in Photoshop. The script opens lots of images (one at a time) they are quite small 2MB and performs multiple actions on each image, saving after each action.

 

My problem is that as the script runs my scratch disks fill up until eventually, they are full, this stops the script prematurely.

 

I have added an action "Edit/Purge/All" that runs each time an image has saved but this is not clearing the scratch disks, they continue to fill up.

 

Does anybody know how to empty the scratch disks while running a script, obviously without closing Photoshop?

TOPICS
Actions and scripting

Views

5.2K

Translate

Translate

Report

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

correct answers 1 Correct answer

People's Champ , Jan 07, 2020 Jan 07, 2020
Here is a working demo solution for Windows.
Checked on CC2020 win7.
You need to assign a hotkey "CtrlF8" for the menu command "Purge All".

Run the script.
It creates a large file three times in a loop and then closes it.
Before cleaning, an alert is issued so that you check the file size.
After cleaning, an alert is issued so that you check the new file size.
Each time, the size from 7GB was reduced to 300MB.
 

 

try {
    for (var i = 0; i < 3; i++)
        {
        app.documents.add();
    
        ap
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 02, 2020 Jan 02, 2020

Copy link to clipboard

Copied

It sounds like you are doing some sort of Batch Process. Why do you need to keep documents open after you open a document modify the document and save an output document. You should then close nosave the document no do a  not Purge all.  Also do you suspend history stated after you open a document.  History states consume lots of resources and slow Photoshop some.  How many history stated do you keep.  If you have many documents  open and have made many changes to them I would think many open documents history states would be written to scratch space. Purge all should clear all history close not onle claers the histort it clears out the document.  If you do not need the document open for more processing after you save the output file close the document you processed.  Even small canvas document with lots of layers can consume a lot of resources. Do not fill the scratch space. In Photoshop open document images and layers are not compressed. I have processed many files and saves thousands of output files without needing to use Purge in a batch process. I'm sure my machine scratch space would have filled if I kept all the document I processed open in Photoshop. The batch took hours to run.....

 

Adobe Image Processor and  the Image Processor Pro plug-in on the web can also process image  files and run many actions on then. They do not keep all processed documents open.   Keeping all document open may well consume all your scratch space.

JJMack

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Hi JJMack, yes each file is closed in sequence, no file is left open unnecessarily.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Hi,

 

Are you saving the files to an external hardrive?

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Hi Simmer1, I have done both, saved to my local drive and external. Both have the problem.

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

For photoshop CS6 and below there is a registry key "ForceScratchTruncation".
If you set it to 1, then after "Purge All" the size of the scratch file is reduced. Unfortunately for CC this does not work.
Canceled?
Perhaps one of the Adobe developers will answer this question ...
 

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Yes, this is cancelled. I don't remember exactly where I read that, but that was about 1 - 2 years ago when Adobe employe said that after update they left visible Purge All option in menu but not working anymore.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Kukurkus, wow, what can I say. This would have been perfect. Adobe, why???

Votes

Translate

Translate

Report

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
Guide ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

I often work with a large number of files, at the limit of the capabilities of RAM and the Photoshop swap file (for my computer). I can say for sure - despite the fact that purge all does not work as before, however, after executing this command, space is freed up inside the swap file (i.e., further work is possible, despite the fact that the disk space is taken)).

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Dmitry, interesting. After adding the "Purge All" I ran the script and saw the hard drive space going down so I just thought that this was not going to work (I exited Photoshop before the script had finished). Are you saying that even if the hard drive space got to zero photoshop would just keep going? I find this hard to believe but it would be great if it was true. Maybe I just need to let the script run to find out.

 

Votes

Translate

Translate

Report

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
Guide ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

Give it a try. In my case, this works.

If I managed to open the required number of files at the same time and start to process them, then with the purge all command after saving the next file, there are no problems. If there is no such command, then I quickly get a message about disk full.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Hi Dmitry, I'm getting to about 3000 images saved with the Purge action in and the same without the Purge action in. I tried adding the action in multiple places in the script but this did not help.

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

r-bin, thanks for this insight!

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

When I hack a batch script I try to reduce the resources that Photoshop will use by toggling off palettes and using suspend history after opening new documents.  There is a nasty bug in Photoshop scripting you can run into when you use suspend history r-bin and I have report the bug to Adobe but adobe does not seem interested in fixing the bug.

r-bin six years ago ps scripting suspendhistor and resizeboundary conflict 

 

myself five years ago nasty scrip bug resize layer back document up one history state 

 

I have help users in the old scripting forum get around the bug. One users script triggered the bug three times,

JJMack

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

I do not use to work with CC Photoshop.
But now I checked here such a thing on CC2018.
Created a 500x500 file.
Increased the size to 15000x15000. Applied filter Add Noise.
Did three times Ctrj + J. Selected all layers and created a smart object.
The paging file size is 7279M.
Closed the file.
The paging file size is 7279M.
Created a 500x500 file.
Did three times Ctrj + J.
The paging file size is 7279M.
Made Purge All.
The paging file size is 381M.

It seems to work. ))
 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Thanks for the test r-bin. I'm not saying that Purge does nothing I'm just saying that when I run my script I can see my hard drive available space falling as the script runs and eventually I get the "Scratch Disks Are Full" error. I've added Purge All to my script but unfortunately, it does not help.

 

I would have hoped that Photoshop would free up space once each file is closed. There really should be no need for Purge all. There are a lot of files but each file is only 2000px wide and there are only two files open at any time.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Post your script perhaps someone can see a problem in it that would cause Photshop to comsume resources.

JJMack

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Hi JJMack, the script is very simple. I'm not sure if it would help as it basically opens each file and then runs an action that does some basic copy and paste (not in the script). The script then saves the file, closes the file and then opens the next and does the same. 

I know that each file is closing so I would not expect the scratch disks to fill up.

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 06, 2020 Jan 06, 2020

Copy link to clipboard

Copied

That is what the Image Processor and Image Processor Pro scripts do.  I have never run our of resources running those  scripts that can run and action or many actions. Image Processor Pro can run as many as 10 Actions on each  image  open as saves as many output files for each image processed.

image.png

JJMack

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

I noticed one feature.
If you call "Purge All" from a script or action, then nothing works. It works only through the menu item.

Perhaps there is a solution using something like the autohotkey program to directly call up the menu. Or do everything manually.
Have you tried doing this manually?
 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Hi r-bin, I'm not sure how I would do this manually while the script is running?

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

I didn’t think. (
I'll try to think )
 

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

I tested the following and it worked:

 

 

purge(PurgeTarget.CLIPBOARDCACHE);

 

 

I have not tested, however, I'm sure that ALLCACHES or HISTORYCACHES or UNDOCACHES would work too. 

 

I just tested with ScriptListener and the raw AM code also works:

 

 

var idPrge = charIDToTypeID( "Prge" );
    var desc335 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var idPrgI = charIDToTypeID( "PrgI" );
    var idClpb = charIDToTypeID( "Clpb" );
    desc335.putEnumerated( idnull, idPrgI, idClpb );
executeAction( idPrge, desc335, DialogModes.NO );

 

EDIT:

I just tested with ALLCACHES and it also worked, at least to clear clipboard content.

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Thanks Stephen, This did not seem to help. Would this not be the same as calling the action "Purge All"?

Votes

Translate

Translate

Report

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
People's Champ ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

Try temporarily setting the length of the Нistory to 1 point and the size of Cache Levels to 2, or better to 1.
Also cancel the auto creation of the First Snapshot in History Options.

Run your process when your disk is guaranteed to be full.

If it helps, then in your script at the time of execution it will be possible to set such parameters.
 

Votes

Translate

Translate

Report

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