1 Reply Latest reply on Mar 11, 2014 10:06 AM by c.pfaffenbichler

    scripting help needed!!

    jcpphotography

      i have a school photography shoot coming up soon each child will have 2 shots which need to be saved into a folder there are 200 children i would like to script this so the first 2files in a folder in sequence are saved or moved to folder 1 {or a choice of folder name} the next 2 shots in sequence into the next folder etc

      the folder ideally would be the name of the first image which would mean that i could rename the images in lightroom to a barcode type system for easy finding of the images later

       

      if this can be created for lightroom even better but i dont mind batch processing in photoshop

      any ideas?

        • 1. Re: scripting help needed!!
          c.pfaffenbichler Level 9

          Does this help (it messes up the date/s, though)?

          // thanks to michael l hale;

          // 2014, use at your own risk;

          var theFolder = Folder.selectDialog ("select folder");

          if (theFolder) {

          var theFiles = theFolder.getFiles(/\.(jpg|tif|eps|psd|png)$/i);

          theFiles.sort();

          var theNumber = theFiles.length;

          if (String(theNumber/2).indexOf(".") == -1) {

          for (var m = theNumber/2 - 1; m >= 0; m--) {

          var theImage = theFiles[m*2];

          var theImage2 = theFiles[m*2+1];

          var basename = theImage.name.match(/(.*)\.[^\.]+$/)[1];

          new Folder(theFolder.fullName+"/"+basename).create();

          var success = theImage.copy(theFolder.fullName+"/"+basename+"/"+theImage.name);

          if (success == true) {theImage.remove()};

          var success = theImage2.copy(theFolder.fullName+"/"+basename+"/"+theImage2.name);

          if (success == true) {theImage2.remove()};

          }

          };

          };