How do I preform a script on an entire folder?
-
16-04-2021 - |
質問
I wrote a script that performs some adjustments, saves then closes the image:
preferences.rulerUnits = Units.PIXELS;
imageWidth = activeDocument.width.as('px');
imageHeight = activeDocument.height.as('px')-30;
activeDocument.resizeCanvas(imageWidth,imageHeight,AnchorPosition.TOPCENTER);
app.activeDocument.save();
app.activeDocument.close();
Is there a way I can get this to run on a whole folder of images?
Thanks
解決
You can try something like this:
#target photoshop
#strict on
main();
function main()
{
var path = "/d/Images/";
var inputFolder = new Folder(path );
var inputFiles = inputFolder.getFiles("*.*");
for(index in inputFiles)
{
// open the file
var fileToOpen = new File(inputFiles[index]);
open(fileToOpen);
// do the processing
preferences.rulerUnits = Units.PIXELS;
imageWidth = activeDocument.width.as('px');
imageHeight = activeDocument.height.as('px')-30;
activeDocument.resizeCanvas(imageWidth,imageHeight,AnchorPosition.TOPCENTER);
app.activeDocument.save();
app.activeDocument.close();
}
}
I did not try, but it should work. Hope it helps.
所属していません StackOverflow