Copy link to clipboard
Copied
Does anyone know if there is a limit to the number of file you can process at any time?
Obviously milage may vary 🙂
I had a simple script that worked. Tried it as a batch process on a folder of 13,918 images and it just fell over. So I re-wrote the script to process a folder 1000 images at a time.
On the fifth or so iteration it fell over and photoshop crashed.
Worked fine after re-starting Photoshop
In the end I managed to process all the images but it was a bit hit and miss.
So, is there a sort of maximum limit set in Photoshop image process wise?
Copy link to clipboard
Copied
No, there is no limit.
I process up to 25 thousand images with one script without problems. Run the script in the code editor and see what error it crashes with - this will help you solve the problem. If you use recursive functions, then the script may crash due to a call stack overflow - I have encountered such an effect, so I always try to first save the list of files into a separate array, and then sequentially process it avoiding recursions. It is also possible that the script crashes due to lack of disk space.
If you post your script, I can try it on my image set.
Copy link to clipboard
Copied
HEllo, In addition to a description or posting the script, listing the specs of the machine could be of help, you can do so easily by posting the contents of Photoshop's Help>System Info... menu, you can remove the section with the plugins, it makes the post very long.
If your post disappears, do not repost it, as it might need to be approved by a moderator. As an alternative you can save it to a .txt file on your computer and attach it on your answer via the forum. (attachments do not post from e-mail)
Copy link to clipboard
Copied
This sounds to me like you're running out of disk space.
With multiple files open at the same time, the size of the scratch file will grow rapidly. It contains all history states for all open documents. That may be orders of magnitude more than any RAM you may have installed, and you could easily need 1 TB or more, depending.
If one file is closed before the next one opens, the scratch file will be kept at a more normal size.
Copy link to clipboard
Copied
Can purging steps be added to the script?
Copy link to clipboard
Copied
..or set History States to 1?
Copy link to clipboard
Copied
I suspect you're right I probably am running out of disk space on C:\
For what it's worth here's the script. It changes 16 bit images to 8 bit save and closes them or just closes them if they are not 16 bits per channel.
// Switch off any dialog boxes
displayDialogs = DialogModes.NO; // OFF
var inFolder = Folder.selectDialog("Please select folder to process");
if (inFolder != null)
{
var fileList = inFolder.getFiles(/\.(png)$/i);
}
var num = fileList.length;
main(fileList);
// Switch any dialog boxes back on again
displayDialogs = DialogModes.ALL; // ALL ON AGAIN
function main(flist)
{
var bits = 8;
for (var i = 0; i < flist.length; i++)
{
// open file
open_it(flist[i]);
// call the source document
var srcDoc = app.activeDocument;
// if there's a document open
// changes it's bit depth
if (documents.length != 0)
{
if(srcDoc.bitsPerChannel == "BitsPerChannelType.SIXTEEN")
{
change_bits_per_channel(bits);
save_and_close_it();
}
else close_it();
} // end documents.length != 0
}
}
function change_bits_per_channel(x)
{
// =======================================================
var idCnvM = charIDToTypeID( "CnvM" );
var desc28 = new ActionDescriptor();
var idDpth = charIDToTypeID( "Dpth" );
desc28.putInteger( idDpth, x ); // bits per channel
var idMrge = charIDToTypeID( "Mrge" );
desc28.putBoolean( idMrge, false );
executeAction( idCnvM, desc28, DialogModes.NO );
}
// function CLOSE IT()
// --------------------------------------------------------
function close_it()
{
// close the image WITHOUT saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
// function SAVE AND CLOSE IT
// ----------------------------------------------------------------
function save_and_close_it()
{
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
// function OPEN IT (filename & path)
// --------------------------------------------------------
function open_it(afilepath)
{
// simple version
var theFile = new File(afilepath);
if (theFile.exists)
{
var id511 = charIDToTypeID( "Opn " );
var desc109 = new ActionDescriptor();
var id512 = charIDToTypeID( "null" );
desc109.putPath( id512, new File(afilepath) );
executeAction( id511, desc109, DialogModes.NO );
}
else // file doesn't exist
{
// alert("Cannot open\n" + afilepath);
}
}