6 Replies Latest reply on Aug 18, 2018 1:31 PM by robg16796643

    Need a script to batch automate "Crop & Straighten"


      So I have a few hundred image files that consist of 3 or 4 scanned photos also called "gang" scanned. The photoshop "Crop & Straighten" ability (located under File-->Automate) is great...But I want to be abe to run a script that will prompt me for a folder to be processed and then run the Crop & Straighten on all the photos, while saving them to another folder called "Edited" or something.  I found a script in the forums for this exact purpose, but it doesn't seem to work in CS5.  I ran it multiple times, it creates the folder "Edited" but nothing is inside of it. The script I found is posted below. Any ideas? I would really appreciate the help!


      #target Photoshop
      var inFolder = Folder.selectDialog("Please select folder to process");
      if(inFolder != null){
      var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
      var outfolder = new Folder(decodeURI(inFolder) + "/Edited");
      if (outfolder.exists == false) outfolder.create();
      for(var a = 0 ;a < fileList.length; a++){
      if(fileList[a] instanceof File){
      var doc= open(fileList[a]);
      var docname = fileList[a].name.slice(0,-4);
      var count = 1;
      var saveFile = new File(decodeURI(outfolder) + "/" + docname +"#"+ zeroPad(count,3) + ".jpg");
      SaveJPEG(saveFile, 12);
      activeDocument.close(SaveOptions.DONOTSAVECHANGES) ;
      function CropStraighten() {
      executeAction( stringIDToTypeID('CropPhotosAuto0001'), undefined, DialogModes.NO );
      function SaveJPEG(saveFile, jpegQuality){
      jpgSaveOptions = new JPEGSaveOptions();
      jpgSaveOptions.embedColorProfile = true;
      jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
      jpgSaveOptions.matte = MatteType.NONE;
      jpgSaveOptions.quality = jpegQuality;
      activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
      function zeroPad(n, s) {
      n = n.toString();
      while (n.length < s) n = '0' + n;
      return n;