不正确的名称保存到activeDocument路径

时间:2019-06-12 09:13:22

标签: save jsx photoshop-script

我有这个脚本,可以将.tif保存到PSD打开的路径。 问题是我无法终生使用特定名称保存文件。始终将其保存为PSD文档名称。

请帮助,这让我发疯。 (尝试将文件另存为“ FOP”)

PIA = app.activeDocument.layerSets.getByName("PIA");
FOP= PIA.layerSets.getByName("FOP");
FOP.visible = true;

var idsave = charIDToTypeID( "save" );
    var desc255 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
        var desc256 = new ActionDescriptor();
        var idBytO = charIDToTypeID( "BytO" );
        var idPltf = charIDToTypeID( "Pltf" );
        var idIBMP = charIDToTypeID( "IBMP" );
        desc256.putEnumerated( idBytO, idPltf, idIBMP );
        var idLZWC = charIDToTypeID( "LZWC" );
        desc256.putBoolean( idLZWC, true );
        var idsaveTransparency = stringIDToTypeID( "saveTransparency" );
        desc256.putBoolean( idsaveTransparency, true );
    var idTIFF = charIDToTypeID( "TIFF" );
    desc255.putObject( idAs, idTIFF, desc256 );
    var idIn = charIDToTypeID( "In  " );
    desc255.putPath( idIn, activeDocument.path, new File("FOP"));
    var idDocI = charIDToTypeID( "DocI" );
    desc255.putInteger( idDocI, 456 );
    var idLyrs = charIDToTypeID( "Lyrs" );
    desc255.putBoolean( idLyrs, false );
    var idsaveStage = stringIDToTypeID( "saveStage" );
    var idsaveStageType = stringIDToTypeID( "saveStageType" );
    var idsaveBegin = stringIDToTypeID( "saveBegin" );
    desc255.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );
executeAction( idsave, desc255, DialogModes.NO );

1 个答案:

答案 0 :(得分:1)

这与您的其他问题类似:putPath仅需要两个参数,因此它将忽略您要向其填充的new File("FOP")。该行应如下所示:

desc255.putPath( idIn, new File(activeDocument.path + "/FOP.tif"));

还要注意文件名前的/activeDocument.path为您提供了没有最后斜杠的路径。