Copy link to clipboard
Copied
Hello,
This question concerns Win 11 Photoshop Batch and Action commands.
I resized about 7000 image files, numbered like this: 0000_FIXED, 0000_MOVING, 0001_FIXED, 0001_MOVING, using a simple one operation Action that applied Image Size to each image, and set up Batch to read the input files and save the output files to a new folder.
Photoshop couldn't handle that operation on that many files at one go, and gives an out-of-memory error part way through. I solved this problem by deleting the input files that had "made it" through the Batch and then restarting the Batch, specifying the correct "Starting Serial #" for the first of the remaining output files in the Destination section of the Batch dialog.
The first time I tried this without deleting the "done" files in the Source folder on disk, I had assumed the "Starting Serial #" value would also apply to the input files in the Source section of the Batch dialog. However, that was just wishful thinking, and it started over using the "0000_FIXED.png" input file, but named the output file starting with the "Starting Serial #" I'd supplied.
The solution of deleting the "done" files in the Source folder, supplying the proper "Starting Serial #" for the rest of the output files, and restarting the Batch worked, in its kludgy fashion, but it made me wonder how the Batch command sees and orders the Source files.
As you know, the order of files on the hard drive often does not match their file name order as seen in Explorer. In this case, the file names show up in numerical order by name (0000_FIXED, 0000_MOVING, 0001_FIXED, 0001_MOVING, etc.) in Explorer but they may be in a more random order on the hard drive.
So, my question is how does the Batch command see and order the files in the Source folder? Does it follow the order as displayed in Windows in Explorer, does it look for a numbering scheme and if that exists follow that instead, or what?
Also, what if the Source files are not named with numerically-ordered suffixes, in what order will Batch process them? Certainly not alphabetically, I trust ...
Last question, how is it that Photoshop, after all these decades, still often retains handles to files and folders that it has opened and that have been closed, necessitating Photoshop being shut down in order to rename/delete/move those files/folders in Windows?
Thanks very much for any insights to this.
Ian J.
The following script will write the date/time and filename of each processed file to a log file.
There must be a file named 'batch-log.txt' on the Desktop.
A file must be opened when recording this script as an action step to create a log file for use with the File > Automate > Batch command.
/*
Batch Logger.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-does-automate-batch-handle-source-image-file-order-when-processing/td-p/14292163
v1.0 - 12th December 2023, Stephen
...
Copy link to clipboard
Copied
Perhaps this link will help you to answer your question:
Copy link to clipboard
Copied
The following script will write the date/time and filename of each processed file to a log file.
There must be a file named 'batch-log.txt' on the Desktop.
A file must be opened when recording this script as an action step to create a log file for use with the File > Automate > Batch command.
/*
Batch Logger.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-does-automate-batch-handle-source-image-file-order-when-processing/td-p/14292163
v1.0 - 12th December 2023, Stephen Marsh
Info: There must be a file named 'batch-log.txt' on the Desktop.
A file must be opened when recording this script as an action step to create a log file for use with the File > Automate > Batch command.
*/
#target photoshop
var thePath = "~/Desktop";
var theName = activeDocument.name.replace(/\.[^\.]+$/, '');
var dateTime = new Date().toLocaleString();
var logFile = new File(thePath + "/" + 'batch-log.txt');
if (logFile.exists) {
try {
var os = $.os.toLowerCase().indexOf("mac") >= 0 ? "mac" : "windows";
if (os === "mac") {
logFileLF = "Unix";
} else {
logFileLF = "Windows";
}
logFile.open("a");
logFile.encoding = "UTF-8";
logFile.lineFeed = logFileLF;
logFile.write(dateTime + "\r" + activeDocument.name + "\r");
logFile.close();
} catch (e) {
//alert(e + ': Line ' + e.line);
}
} else {
alert("The 'batch-log.txt' file can't be found on the: " + thePath);
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Thanks for your reply to this question, Stephen, and I apologize for my late "Marked as Correct Answer."
I still haven't had time to test your answer, but given my experience with how Batch functioned for me, I believe you're correct. "Alphanumeric" sort order is probably the case, and so it treats numeric prefixes (like "0000", "0001", etc.) correctly. You're point to use numeric prefixes to force order is a good one and I can confirm that that works. I was asking specifically about how Batch sees the file order in a folder, but I appreciate the code as well.
Thanks!
Ian J.