Question
Photoshop .jsx scripting code I've run 100 times suddenly failing to run + producing errors. Why?
I've been successfully using this jsx code to run batches in Photoshop:
function runBatchAction(inputPath, outputPath, actionName, actionSet, wildcard) {
wildcard = wildcard || /\.(jpg|jpeg|png)$/i;
var files = new Folder(inputPath).getFiles(function(file) { return wildcard.test(file.name) });
var options = new BatchOptions();
options.destination = BatchDestinationType.FOLDER;
options.destinationFolder = new Folder(outputPath);
options.overrideOpen = false;
options.overrideSave = true;
options.fileNaming = [FileNamingType.DOCUMENTNAMEMIXED, FileNamingType.EXTENSIONLOWER];
app.batch(files, actionName, actionSet, options);
// After batch processing, iterate over the files and replace dashes with spaces
var outputFolder = new Folder(outputPath);
var outputFiles = outputFolder.getFiles();
for (var i = 0; i < outputFiles.length; i++) {
var outputFile = outputFiles[i];
if (outputFile.name.indexOf('-') !== -1) {
var newFileName = outputFile.name.replace(/-/g, ' ');
outputFile.rename(newFileName);
}
}
}
runBatchAction(
"C:\\Users\\anton\\Pictures\\CURRENT IMAGE FOLDER", // input folder
"C:\\Users\\anton\\Pictures\\AUTOMATION ASSETS\\PHOTOSHOP FILES\\INTERMEDIATE IMAGES", // output folder
"mockup resizing v1", // action name
"IMAGE RESIZING" // set name
);
It's now failing to run correctly, and I get this error in my Python script:
Traceback (most recent call last):
File "c:\Users\anton\Documents\photoshop-scripting\image-resizing-v1.py", line 459, in <module>
jsx_file_path = r"C:\Users\anton\Documents\photoshop-scripting\batch-photoshop-steps-v1.jsx"
File "<COMObject Photoshop.Application>", line 3, in DoJavaScriptFile
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'General Photoshop error occurred. This functionality may not be available in this version of Photoshop.\n- Error 1220: Illegal Argument\rLine: 63\r-> app.batch(files, actionName, actionSet, options);', None, 0, -2147212704), None)
File "c:\Users\anton\Documents\photoshop-scripting\image-resizing-v1.py", line 459, in <module>
jsx_file_path = r"C:\Users\anton\Documents\photoshop-scripting\batch-photoshop-steps-v1.jsx"
File "<COMObject Photoshop.Application>", line 3, in DoJavaScriptFile
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'General Photoshop error occurred. This functionality may not be available in this version of Photoshop.\n- Error 1220: Illegal Argument\rLine: 63\r-> app.batch(files, actionName, actionSet, options);', None, 0, -2147212704), None)
Any clue why this would suddenly start triggering this error, after this exact jsx code has been working just fine this whole time?
