Skip to main content
Retsied
Known Participant
February 17, 2019
해결됨

"Save as" png with same name as psd plus "-01" or some given text

  • February 17, 2019
  • 1 답변
  • 2309 조회

Hello,

I'm trying to figure out a way to save a png, in which the filename is the same as the psd, plus some given text at the end.

For example, if I have two .psd files named "Apple.psd" and "Orange.psd", I would like to be able to run the same script or action to save these files as "Apple_addedText" and "Orange_addedText", where addedText can be anything that I define in the script or action.

Any help is much appreciated, thanks!

    이 주제는 답변이 닫혔습니다.
    최고의 답변: Stephen Marsh

    Stephen,

    This is very close to what I need, thanks for helping! What I'm really trying to do, however, is a little different. Sorry if I wasn't clear.

    What I'd like is this:

    1.) I have a folder with several different psd files

    2.) I will run a Batch Action on these files to edit all their appearances (I believe this was your question earlier about any resizing, which I must have misunderstood)

    3.) The last step in the given action, I would like to be the Save for Web using the nomenclature "psdFilename_mySuffix"

    4.) Close and don't save psd.

    It seems you answered this in my other thread, which I apologize for tagging onto that post and asking the same question. I will try this with Image Processor Pro as recommended and let you know how it goes.

    UPDATE: I've downloaded and followed the instructions for installing IPP, however don't have the listed folder (/Developer) on my Mac so chose to install in a different location. The install seemed to work, but when I go to File > Automate, Image Processor Pro is missing. If I leave the setting to install at /Developer, photoshop closes as soon as I hit Next. Also, will this even work since I'm opening psd files and saving as png? All the examples and tutorial I've seen for IPP open actual images (jpg).

    Thanks!


    You can indeed use IPP instead of Batch, it will work with all different file formats and can rename and run an action, so a custom dedicated script is not really required for what you want to do as IPP is a “Swiss army knife” and can “do it all”. In this case, you don’t wish to record the IPP settings into an action, as IPP is performing the batch and running any actions required. Other scripts can be recorded into actions for use with IPP, IPP is not intended to be recorded into an action for use with Batch processing, but IPP can be recorded into an action for non batch use. IPP can be installed manually from a .zip or automated from the Adobe ExtensionManager or a 3rd party extension manager application. The manual installation instructions have to be followed exactly.

    EDIT: Here is a script that I have changed from saving out JPG files to PNG, this should hopefully now do what you want.

    /*

    Scripted Save for Web sRGB PNG with SUFFIX.jsx   

    Export Save for Web a PNG24 transparent version of the original image converted to sRGB using a

    filename suffix of "_mySuffix" and close down the original file without saving

    https://forums.adobe.com/message/7971520

    https://forums.adobe.com/message/10935403 – changed from jpg to png

    */

    #target photoshop;

    // displayDialogs = DialogModes.NO;

    if (documents.length) {

        var doc = activeDocument;

        if (doc.colorProfileName.substring(0, 4) != "sRGB")

        doc.convertProfile("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, false);

        try {

            Path = doc.path;

        }

        catch (e) {

            // alert("this document has not been saved.")

            Path = Folder.desktop;

        }

        var Name = doc.name.replace(/\.[^\.]+$/, '');

        var saveFile = File(Path + "/" + Name + "_mySuffix" + ".png"); // Change "_mySuffix" to another valid filename string

        SaveForWeb(saveFile);

    }

    function SaveForWeb() {

        var sfwOptions = new ExportOptionsSaveForWeb();

        sfwOptions.format = SaveDocumentType.PNG;

        sfwOptions.PNG8 = false;

        sfwOptions.interlaced = false;

        sfwOptions.transparency = true;

        sfwOptions.includeProfile = true;

        //sfwOptions.matte = true;

        //sfwOptions.matteColor = 0, 0, 0;

        activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);

       

    };

    doc.close(SaveOptions.DONOTSAVECHANGES);

    1 답변

    Stephen Marsh
    Community Expert
    Community Expert
    February 17, 2019

    Is the psd open and you wish to run the script to create the png?

    Or are you wishing to batch process a folder, creating the png versions from any psd files in the folder?

    Should this be a save as, export or legacy save for web?

    Will there be any resizing?

    Will there be a conversion to sRGB?

    Anything else?

    It would help if you listed out exactly what you would do manuallly step by step.

    Retsied
    Retsied작성자
    Known Participant
    February 17, 2019

    Yes, psd will be open when creating png via Batch. No resizing of anything, just want to open the psd and save a png either by Save As or Save for Web, no other conversions. 

    Stephen Marsh
    Community Expert
    Community Expert
    February 17, 2019

    Sorry, I meant is this “one file at a time” with the current/active file being saved… Or do you wish to process a batch of PSD files from a folder, creating multiple PNG files from a single script run?

    What is is the intended use of the PNG?

    What colour space is the PSD? sRGB, Adobe RGB, ProPhoto?

    Save as retains metadata such as PPI, while export and save for web removes this PPI metadata.