7 Replies Latest reply on Mar 31, 2014 3:15 PM by Chuck Uebele

    Script to Save images in alternate folder before running an action

    bfox2718 Level 1

      New to scripting here, and need some help....

       

      I need to do the following:

       

      1) copy original images from a specific folder (customerid\Raw_Images) and save them to an alternate folder (customerid\Raw_Images_Original)

      2) Run a particular action in photoshop to enhance the images

      3) Overwrite the image in Raw_Images with the newly enhanced one.

      4) Save a thumbnail 400px wide in a folder (customerid\Thumbnails)

      5) Prompt the user that the customer's images have been enhanced.

       

      Any help would be appreciated.

       

      I have done similar projects before but cannot seem to successfully combine all of my past experience to get this off the ground.

       

      Thanks in advance!

       

       

      I have this code already below, but how do I now set it up to prompt my user to select a customer folder to run it on?

       

       

      // makes backup of image and applies enhancements to orig and thumbs

      // be advised: this  overwrites existing jpgs of the same name without prompting.

       

       

      #target photoshop;

      if (app.documents.length > 0) {}

      var thedoc = app.activeDocument;

       

       

      // getting the name and location;

      var docName = thedoc.name;

      if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}

      else {var basename = docName};

       

       

       

       

      // getting the location, if unsaved save to desktop;

      try {var docPath = thedoc.path}

      catch (e) {var docPath = "~/Desktop"};

       

       

      // jpg options;

      var jpegOptions = new JPEGSaveOptions();

      jpegOptions.quality = 9;

      jpegOptions.embedColorProfile = true;

      jpegOptions.matte = MatteType.NONE;

       

       

      //save jpg as a copy into Raw Images Orig Folder:

      thedoc.saveAs((new File(docPath+'/../'+'/Raw_Images_Original/'+docName)),jpegOptions,true);

       

       

      doAction("Sketch","Spring 2014");

       

       

      thedoc.saveAs((new File(docPath+'/../'+'/Raw_Images/'+docName)),jpegOptions,true);

       

       

      //save thumnail:

      thedoc.resizeImage(UnitValue(400, "px"), undefined, 300, ResampleMethod.BICUBIC);

      thedoc.saveAs((new File(docPath+'/../'+'/Thumbnails/'+docName)),jpegOptions,true);

       

       

       

       

      //close the Document

      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);