What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

batch and subfolders


Jerryj

New Member
Messages
3
Likes
0
hi,

I have a folder structure of subfolders with jpeg's in them.

I'd like to 'Save for web' them , keep the same folder structure and also the same names for the images.

I made an action that does Save for web. According to Adobe the settings should be
File > Automate > Batch>
Inculde all subfolders checked
Save and Close
Override Action checked

and I tried many other settings,
but the images tend to be saved in the destination folder of the image that I created the action with, instead of their original folder.

Is it possible what I want and if so, how?

Thanks!

Jeff.
 
This script will process a folder and it's sub folders of JPG's and save overwrite the originals with the new SFW JPG's
Alter the quality to suit.

Code:
var imageFolder = Folder.selectDialog("Select the folder with JPGs to process"); 
if (imageFolder != null)  processFolder(imageFolder);

function processFolder(folder) {
    var fileList = folder.getFiles()
     for (var i = 0; i < fileList.length; i++) {
        var file = fileList[i];
  if (file instanceof File && file.name.match(/\.jpg$/i)) {
     			open(file);
var doc = app.activeDocument;
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var saveFile = new File(decodeURI(activeDocument.fullName.fsName)); 
saveFile.remove();
SaveForWeb(saveFile,60); // set quality to suit
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;      
		 
  } else 
if (file instanceof Folder) {
       processFolder(file);
     }
   }
}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb(); 
   sfwOptions.format = SaveDocumentType.JPEG; 
   sfwOptions.includeProfile = false; 
   sfwOptions.interlaced = 0; 
   sfwOptions.optimized = true; 
   sfwOptions.quality = jpegQuality;
app.activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}
 
i had the same problem!

how do i use this script? when i put the code in script editor it shows "syntax error: a identifier cant go after this identifier" sorry, newbie here, can anyone help please?
 
got to photoshop > presets > scripts and open an existing script. Replace the code in there with the code provided in this thread and save the file under another name. Don't know much about .jsx files but that worked for me. No errors. Make sure you copy the entire code, don't forget the last bracket for instance.
 
Hi there
I like this script. I wonder how easy it would be to tweak it so that there is also a resize facility?
Andy
 

Back
Top