Skip to main content
Participant
May 30, 2022
Question

OPEN SAVE WHOLE FOLDER - I'm in need to create a specific script, but i don't know how

  • May 30, 2022
  • 3 replies
  • 294 views

Script to do:

 

  1. Open image file "xx-xx-xx (1).jpg" in folder (Y:\products\xx-xx-01\graphic)
  2. Create folder (Y:\products\xx-xx-01\offer)
  3. Save it in folder (Y:\products\xx-xx-01\offer) in two dimensions renemeing them to (large.jpg) nad (small.jpg)
  4. repeat this proces for: "xx-xx-xx (1).jpg" in folder (Y:\products\xx-xx-02\graphic) saving it in (Y:\products\xx-xx-02\offer) and so one for something like 1000+ products

 

Can someone help me with this? This thing by using action's or even droplets will take me so much time. Is there is a way to automet this?

I have no scripting experience

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
June 1, 2022

@Mark-S – please let the forum know how you go...

Mark-SAuthor
Participant
June 1, 2022

Of course :), sure i do - just another (more important) task emerges from the abyss at the moment 😜 and this one is put aside for a time being.

c.pfaffenbichler
Community Expert
Community Expert
May 31, 2022

You may have to correct the Folder-path (I am not a Windows-user) and the Script saves only a direct jpg-copy for psd, psb and tif and names it »large.jpg«. 

But figuring out how to include jpg into the images to be processed and create the second jpg might be good practice for you. 

Just make sure not to inadvertently edit the original. 

// saves jpg into folder "offer" next to folder containing image;
// be advised: this  overwrites existing jpgs of the same name without prompting. 
// 2022, use it at your own risk;
var thePath = "Y:/products";
var theFiles = retrieveFiles (Folder(thePath), []);
// jpg options;
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 9;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
// process files;
for (var m = 0; m < theFiles.length; m++) {
var thedoc = app.open(theFiles[m]);
// getting the name and location;
var docName = thedoc.name;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
// getting the location;
var docPath = File(theFiles[m]).parent.parent+"/offer";
if (Folder(docPath).exists == false) {Folder(docPath).create()};
//save jpg as a copy:
thedoc.saveAs((new File(docPath+'/'+'large'+'.jpg')),jpegOptions,true);
thedoc.close()
};
//that’s it; thanks to xbytor;
////// get psds and tifs from subfolders //////
function retrieveFiles (theFolder, theFiles) {
	if (!theFiles) {var theFiles = []};
	var theContent = theFolder.getFiles();
	for (var n = 0; n < theContent.length; n++) {
		var theObject = theContent[n];
		if (theObject.constructor.name == "Folder") {
			theFiles = retrieveFiles(theObject, theFiles)
			};
		if (theObject.name.slice(-4).match(/\.(psb|tif|psd)$/i) ) {
			theFiles.push(theObject)
			}
		};
	return theFiles
	};

 

Stephen Marsh
Community Expert
Community Expert
May 30, 2022

The output filename, file format and resized sizes are not clear, however that is not too critical for now...

 

Although a custom script could be written, I'd first look at pre-made generic scripts, such as:

 

Image Processor Pro:

ImageProcessorPro-3_2b5.zip

https://sourceforge.net/projects/ps-scripts/files/Image%20Processor%20Pro/v3_2%20betas/

 

Animated GIF example, a single run creating two different sizes:

 

If you are processing 1000's of input images into two output sizes, you will likely only wish to process one image folder at a time as you may experience memory related errors with so many files (Photoshop does not always gracefully handle "industrial" volumes of images when batching).