6 Replies Latest reply on May 24, 2018 3:42 PM by r-bin

    Saving a photo to a different folder and renaming it.

    shek faip85609166 Level 1

      Hi guys,

       

      I'm trying to make a script that allow me to save a photo to a different folder and rename it to something else.

       

      I got the saving to a different folder part done (save to the PackageImages) but it's not renaming it. I want the photo to rename as "key".

       

      This is my script so far:

       

      var doc = app.activeDocument

       

      if (app.documents.length > 0) {

        var thedoc = app.activeDocument;

        var docName = thedoc.name;

       

      var docFolder = Folder( doc.path  );

      var newFolder = Folder( docFolder.parent + '/' + "PackageImages");

      var NewName = docName.replace("docName", "key");

       

        var jpegOptions = new JPEGSaveOptions();

        jpegOptions.quality = 12;

        jpegOptions.embedColorProfile = true;

        jpegOptions.matte = MatteType.NONE;

        var filename = newFolder + '/' + NewName + '.jpg';

          $.writeln(filename);

        thedoc.saveAs((new File(filename)), jpegOptions, true);

      };

       

      It would be very helpful if someone could tell me what Ive done wrong. Hope someone helps me figuring out how to fix this