how to edit a script

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: xbytor, DavideBarranca, Paul MR

r4nd3r
Posts: 6
Joined: Fri Aug 05, 2016 12:29 pm

how to edit a script

Postby r4nd3r » Thu Aug 25, 2016 2:42 pm

Hi

I need to add in a script only the " include all subfolders "

the script is the " Manual batch "


https://github.com/cgencer/ps-scripting ... al%20Batch

it would be possible?



User avatar
Dormeur74
Posts: 11
Joined: Mon Oct 03, 2016 4:56 am

Re: how to edit a script

Postby Dormeur74 » Mon Oct 03, 2016 3:38 pm

Hi,

If you want to apply a script to the photos that are in subfolders, I think that the best way is to use a recursive function.
Here is an example I wrote to extract width and height of the photos found in a folder (and its subfolders, of course). Hope it will help.

Code: Select all

// Enables double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
app.bringToFront();

var inputFolder = Folder.selectDialog("Select the top folder where your images are : ");

if (inputFolder != null) {
   filesArray = scanFolder(inputFolder);
   if (filesArray.length > 0)
   {
      for (i = 0;i<filesArray.length;i++)
      {
         docRef = filesArray[i];
         open(docRef);
         imgWidth = app.activeDocument.width;
         imgHeight = app.activeDocument.height;
         alert(imgWidth+" x " +imgHeight);
      }
   }
}
alert("Done !");

// Recursive function
function scanFolder(folder) {
   var filesArray = [],
   fileList = folder.getFiles(),i, file;
   
   for (i = 0; i < fileList.length; i++) {
      file = fileList[i];
      if (file instanceof Folder) {
         filesArray = filesArray.concat(scanFolder(file));
      }
      else if (file instanceof File && file.name.match(/\.(jpg|tif|psd|bmp|gif|png|)$/i)) {
         filesArray.push(file);
      }
   }
   return filesArray;
}
An empty brain is the devil's shop.


Return to “Photoshop Scripting: Code Snippets”

Who is online

Users browsing this forum: No registered users and 1 guest