如何在整个文件夹上执行脚本?

时间:2012-01-12 00:51:55

标签: photoshop-script

我写了一个执行一些调整的脚本,保存然后关闭图像:

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();

有没有办法让我在整个图像文件夹上运行?

由于

1 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情:

#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();

    }
}

我没有尝试,但它应该工作。 希望它有所帮助。