9 Replies Latest reply on Aug 19, 2010 2:45 PM by Muppet Mark-QAl63s

    Long Shot Scripting for Server Organization - Help?

    KS_Coastal Level 1

      I have plenty of scripts to identify the res of an image, but now I am looking to put one together which will look at my server, identify amongst thousands of files at a time, the PS, .jpg and .tiff files only, checking the res and copying those that are 300 dpi or greater only to a local folder. From there I have a whole other workflow to reres to low res for FPO files and rename into their own folder. Making sense enough for a reply?

        • 1. Re: Long Shot Scripting for Server Organization - Help?
          JJMack Most Valuable Participant

          look at this thread it may be of some help or give you an idea. http://forums.adobe.com/thread/693986?tstart=0

          1 person found this helpful
          • 2. Re: Long Shot Scripting for Server Organization - Help?
            Paul Riggott Level 6

            This should do PSD, JPG and TIF files..

            /*
                Run the script from ESTK
            Make sure you select :-
            View -  Show Items from Subfolders  
            if you want sub folders
            */
            #target bridge
            main();
            function main(){
            var count = 0;
            var copyFolder =  Folder.selectDialog( "Please select folder to copy files to.");
            app.document.selectAll();
            if(copyFolder == null) return;
            var thumbs = app.document.getSelection("psd, jpg, tif");
            for(var a in thumbs){ 
            var t= new Thumbnail(thumbs[a]);
            if(t.core.quickMetadata.xResolution >=300){
            thumbs[a].spec.copy(File(copyFolder + "/"+ decodeURI(thumbs[a].name)));
            count++;
                 }
            }
            alert("Total number of files copied = " + count); 
            }
            

            NB if any files have the same name they will be overwritten in the copy folder! It might be best doing a folder at a time.

            • 3. Re: Long Shot Scripting for Server Organization - Help?
              KS_Coastal Level 1

              Works great for the first 100 or so images, but I have 1500 or so. I'm going to break it down a bit and should be fine. Thanks!!!

              • 4. Re: Long Shot Scripting for Server Organization - Help?
                KS_Coastal Level 1

                Hi Paul,

                 

                Any idea why the script all of the sudden will only copt the tif files?

                • 5. Re: Long Shot Scripting for Server Organization - Help?
                  Paul Riggott Level 6

                  Sorry, no. I have done some ckecks and it seems to selecting the correct files, I thought it might have been because the extensions were not lower case, but it still picks them out even if mixed case.

                  I have put some counts in, allthough they will only tell you what has been selected. Can you find a file that you know it should select but doesn't? If so it might be a problem with the metadata and I could write something that would tell us what the script is seeing for that file.

                   

                  #target bridge
                  main();
                  function main(){
                  var count = 0;
                  var psdCount = 0;
                  var jpgCount = 0;
                  var tifCount =0;
                  var copyFolder =  Folder.selectDialog( "Please select folder to copy files to.");
                  app.document.selectAll();
                  if(copyFolder == null) return;
                  var thumbs = app.document.getSelection("psd, jpg, tif");
                  alert("Processing "+thumbs.length + " Files");
                  for(var a in thumbs){ 
                  var t= new Thumbnail(thumbs[a]);
                  if(t.core.quickMetadata.xResolution >=300){
                  thumbs[a].spec.copy(File(copyFolder + "/"+ decodeURI(thumbs[a].name)));
                  count++;
                  if(thumbs[a].name.match(/jpg$/i)) jpgCount++;
                  if(thumbs[a].name.match(/psd$/i)) psdCount++;
                  if(thumbs[a].name.match(/tif$/i)) tifCount++;
                       }
                  }
                  alert("Total number of files copied = " + count + "\rJPGs = "+ jpgCount+"\rPSDs = "+ psdCount + "\rTIFs = "+ tifCount); 
                  }
                  
                  • 6. Re: Long Shot Scripting for Server Organization - Help?
                    KS_Coastal Level 1

                    I see the edit you made and am going to check but can't get back until tomorrow. I can see many many psd and jpg files it should be selecting but isn't. There is a ton of metadata in these files, so it'd be a miracle if we could find out if that (or a part of that metadata) is an issue. I'll poke a bit more and give you an update in the AM. Thanks so much for getting back to me!

                    • 7. Re: Long Shot Scripting for Server Organization - Help?
                      KS_Coastal Level 1

                      Is it tomorrow yet??? I ran the script, and it tells me it is processing 2 (for example) files, but has the error/yield symbol on it and does not copy. The first script doesn't even see the jpg files. Am I making sense?

                      • 8. Re: Long Shot Scripting for Server Organization - Help?
                        Paul Riggott Level 6

                        Yes that symbol is ok as it is a Script Alert.

                        Please could you run this on those files, it will give a Script Alert for each of the files giving you the Filename and the resolution of the file. Does any of them report undefined ?

                         

                        #target bridge
                        main();
                        function main(){
                        app.document.selectAll();
                        var thumbs = app.document.getSelection("psd, jpg, tif");
                        for(var a in thumbs){ 
                        var t= new Thumbnail(thumbs[a]);
                        alert(decodeURI(thumbs[a].name) + " resolution = " + t.core.quickMetadata.xResolution );
                            }
                        }
                        
                        • 9. Re: Long Shot Scripting for Server Organization - Help?
                          Muppet Mark-QAl63s Level 4

                          If you are on a mac then you could try this in the ESTK with either bridge or photoshop as your target app. It passes a string to the system that just writes a list as a text file to your documents folder… If you compare the list and it looks good you can either parse it with JavaScript or pipe it to another shell like 'cp'

                           

                          #target bridge
                           
                          var f = Folder.selectDialog('Select a Folder to search in?');
                           
                          var shellString = "mdfind -onlyin ";
                          shellString += "'" + f.fsName + "/'";
                          shellString += " '(kMDItemResolutionHeightDPI > 299 || kMDItemResolutionWidthDPI > 299)";
                          shellString += " && (kMDItemFSName == *.tif || kMDItemFSName == *.psd || kMDItemFSName == *.jpg)' > ";
                          shellString += "~/Documents/StdOut.txt";
                           
                          //$.writeln(shellString); Just my test
                           
                          var sh = app.system(shellString);
                          

                           

                          I only did a small amount of testing here but it looked OK…