Pass images of folders through photoshop script/droplet

How it works now

I have folders on my desktop labeled

Design_WKxxDone
Free_WKxxDone etc.

XX being the current week.

I drag this onto a photoshop droplet that corresponds to the folder name, so Design_WKxxDone would be placed over the Design droplet. ( I press and hold alt this gives me a prompt to enter the week number. Then it runs copying the images down to various locations in different sizes.

See the PS-Script below is the droplet script that it runs, I’m not looking to alter this script as I have a number like it.

The normal method of running this script is that by holding the alt key allows you to input the week if you don’t it will use the previously used week. This then chucks the images into various folders using the week number (this would be the same as the one used in the fore mentioned folder. Design_WKxxDone

There are a number of request I am asking.

I would like to be able to have an onscreen windows where I can load up all the folders that need to be processed

So folder A using Droplet A
Folder B using Droplet B etc.

It would need to take the Week number from the folder name (it would always be the only number in the folder name it would follow after WK in the folder name). run the dropets sequencially (as photoshop will only allow one after another) and Ideally a schedule time so I can let it run over night, alternatively I set it to run as the last thing that I do in the day.

As some may have seen from using this site, I have very useless knowledge of Applescript and have had a lot of help with my ideas. I am hoping to find someone who can compile this as I would be lost doing it myself. I’ve got my applescript book so I am off to learn but I don’t think I will be compiling anything quite like this just yet.

#target photoshop
//
// Design.jsx
//
//==================== Design ==============
//
Design();

function Design() {

try {
var desc = app.getCustomOptions(“21878580-3f53-11e0-9207-0800200c9a66”);
var userInput = desc.getString(stringIDToTypeID(‘userInput’));
}catch(e) {}
if(undefined == userInput || ScriptUI.environment.keyboardState[‘altKey’] || DialogModes.ALL == app.playbackDisplayDialogs ){
var userInput = prompt(‘Design, Enter Week Number’,‘default input’);
}
if(userInput != null){// make sure the user did not cancel. May want to add other checks such as length
try{
var desc = app.getCustomOptions(“21878580-3f53-11e0-9207-0800200c9a66”);
}catch(e){
var desc = new ActionDescriptor();
}
desc.putString (stringIDToTypeID(‘userInput’) , userInput );
app.putCustomOptions( “21878580-3f53-11e0-9207-0800200c9a66”, desc, true );
var localFolder = new Folder(‘~/Pictures/2011-2012/WK’+userInput+“/Design”);
if(!localFolder.exists) localFolder.create();
var highResFolder = new Folder(localFolder+‘/Design_WK’+userInput+“_HR”);
if(!highResFolder.exists) highResFolder.create();
var networkFolder = new Folder(‘/Volumes/2012/Week’+userInput+‘/Design_WK’+userInput+“_LR”);
if(!networkFolder.exists) networkFolder.create();
var saveName = decodeURI(app.activeDocument.name);
saveName.match(/(.)(.[^.]+)/) ? saveName = saveName.match(/(.)(.[^.]+)/):saveName = [saveName, saveName];
saveName = saveName[1];

// Flatten Image
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(stringIDToTypeID(‘flattenImage’), undefined, dialogMode);
};

// Smart Sharpen
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(‘#Prc’), 164);
desc1.putUnitDouble(charIDToTypeID(‘Rds ‘), charIDToTypeID(’#Pxl’), 0.9);
desc1.putInteger(charIDToTypeID(‘Thsh’), 0);
desc1.putInteger(charIDToTypeID(‘Angl’), 0);
desc1.putBoolean(stringIDToTypeID(“moreAccurate”), false);
desc1.putEnumerated(charIDToTypeID(‘blur’), stringIDToTypeID(“blurType”), charIDToTypeID(‘GsnB’));
desc1.putString(stringIDToTypeID(“preset”), “Default”);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(‘#Prc’), 0);
desc2.putUnitDouble(charIDToTypeID(‘Wdth’), charIDToTypeID(‘#Prc’), 50);
desc2.putInteger(charIDToTypeID(‘Rds ‘), 1);
desc1.putObject(charIDToTypeID(‘sdwM’), stringIDToTypeID(“adaptCorrectTones”), desc2);
var desc3 = new ActionDescriptor();
desc3.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(’#Prc’), 0);
desc3.putUnitDouble(charIDToTypeID(‘Wdth’), charIDToTypeID(‘#Prc’), 50);
desc3.putInteger(charIDToTypeID('Rds '), 1);
desc1.putObject(charIDToTypeID(‘hglM’), stringIDToTypeID(“adaptCorrectTones”), desc3);
executeAction(stringIDToTypeID(‘smartSharpen’), desc1, dialogMode);
};

// Save
function step3(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putInteger(charIDToTypeID(‘EQlt’), 12);
desc2.putEnumerated(charIDToTypeID(‘MttC’), charIDToTypeID(‘MttC’), charIDToTypeID(‘None’));
desc1.putObject(charIDToTypeID(‘As ‘), stringIDToTypeID(“JPEGFormat”), desc2);
desc1.putPath(charIDToTypeID(‘In ‘), new File(highResFolder+’/’+saveName+’.jpg’));
desc1.putBoolean(charIDToTypeID(‘LwCs’), true);
executeAction(charIDToTypeID(‘save’), desc1, dialogMode);
};

// Select
function step4(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID(‘HstS’), charIDToTypeID(‘Ordn’), charIDToTypeID(‘Prvs’));
desc1.putReference(charIDToTypeID(‘null’), ref1);
executeAction(charIDToTypeID(‘slct’), desc1, dialogMode);
};

// Image Size
function step5(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(charIDToTypeID(‘Wdth’), charIDToTypeID(‘#Pxl’), 1000);
desc1.putBoolean(stringIDToTypeID(“scaleStyles”), true);
desc1.putBoolean(charIDToTypeID(‘CnsP’), true);
desc1.putEnumerated(charIDToTypeID(‘Intr’), charIDToTypeID(‘Intp’), charIDToTypeID(‘Bcbc’));
executeAction(stringIDToTypeID(‘imageSize’), desc1, dialogMode);
};

// Smart Sharpen
function step6(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(‘#Prc’), 164);
desc1.putUnitDouble(charIDToTypeID(‘Rds ‘), charIDToTypeID(’#Pxl’), 0.9);
desc1.putInteger(charIDToTypeID(‘Thsh’), 0);
desc1.putInteger(charIDToTypeID(‘Angl’), 0);
desc1.putBoolean(stringIDToTypeID(“moreAccurate”), false);
desc1.putEnumerated(charIDToTypeID(‘blur’), stringIDToTypeID(“blurType”), charIDToTypeID(‘GsnB’));
desc1.putString(stringIDToTypeID(“preset”), “Default”);
var desc2 = new ActionDescriptor();
desc2.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(‘#Prc’), 0);
desc2.putUnitDouble(charIDToTypeID(‘Wdth’), charIDToTypeID(‘#Prc’), 50);
desc2.putInteger(charIDToTypeID(‘Rds ‘), 1);
desc1.putObject(charIDToTypeID(‘sdwM’), stringIDToTypeID(“adaptCorrectTones”), desc2);
var desc3 = new ActionDescriptor();
desc3.putUnitDouble(charIDToTypeID(‘Amnt’), charIDToTypeID(’#Prc’), 0);
desc3.putUnitDouble(charIDToTypeID(‘Wdth’), charIDToTypeID(‘#Prc’), 50);
desc3.putInteger(charIDToTypeID('Rds '), 1);
desc1.putObject(charIDToTypeID(‘hglM’), stringIDToTypeID(“adaptCorrectTones”), desc3);
executeAction(stringIDToTypeID(‘smartSharpen’), desc1, dialogMode);
};

// Select
function step8(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putOffset(charIDToTypeID(‘HstS’), -3);
desc1.putReference(charIDToTypeID(‘null’), ref1);
executeAction(charIDToTypeID(‘slct’), desc1, dialogMode);
};

// Select
function step9(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(charIDToTypeID('Lyr '), “Original Image”);
desc1.putReference(charIDToTypeID(‘null’), ref1);
desc1.putBoolean(charIDToTypeID(‘MkVs’), false);
executeAction(charIDToTypeID(‘slct’), desc1, dialogMode);
};

// Select
function step10(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(charIDToTypeID('Lyr '), “BACKGROUND”);
desc1.putReference(charIDToTypeID(‘null’), ref1);
desc1.putEnumerated(stringIDToTypeID(“selectionModifier”), stringIDToTypeID(“selectionModifierType”), stringIDToTypeID(“addToSelection”));
desc1.putBoolean(charIDToTypeID(‘MkVs’), false);
executeAction(charIDToTypeID(‘slct’), desc1, dialogMode);
};

// Delete
function step11(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID(‘Ordn’), charIDToTypeID(‘Trgt’));
desc1.putReference(charIDToTypeID(‘null’), ref1);
executeAction(charIDToTypeID('Dlt '), desc1, dialogMode);
};

// Merge Visible
function step12(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(stringIDToTypeID(‘mergeVisible’), undefined, dialogMode);
};

// Set
function step13(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID(‘Ordn’), charIDToTypeID(‘Trgt’));
desc1.putReference(charIDToTypeID(‘null’), ref1);
var desc2 = new ActionDescriptor();
desc2.putString(charIDToTypeID('Nm '), “Layer 0”);
desc1.putObject(charIDToTypeID('T '), charIDToTypeID('Lyr '), desc2);
executeAction(charIDToTypeID(‘setd’), desc1, dialogMode);
};

// Save
function step13a(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putEnumerated(stringIDToTypeID(“PNGInterlaceType”), stringIDToTypeID(“PNGInterlaceType”), stringIDToTypeID(“PNGInterlaceNone”));
desc2.putEnumerated(stringIDToTypeID(“PNGFilter”), stringIDToTypeID(“PNGFilter”), stringIDToTypeID(“PNGFilterAdaptive”));
desc1.putObject(charIDToTypeID(‘As ‘), stringIDToTypeID(“PNGFormat”), desc2);
desc1.putPath(charIDToTypeID(‘In ‘), new File(networkFolder+’/’+saveName+’.png’));
desc1.putBoolean(charIDToTypeID(‘LwCs’), true);
executeAction(charIDToTypeID(‘save’), desc1, dialogMode);
};

// Close
function step18(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
executeAction(charIDToTypeID('Cls '), undefined, dialogMode);
};

step1(); // Flatten Image
step2(); // Smart Sharpen
step3(); // Save
step4(); // Select
step5(); // Image Size
step6(); // Smart Sharpen
step8(); // Select
step9(); // Select
step10(); // Select
step11(); // Delete
step12(); // Merge Visible
step13(); // Set
step13a(); // Save
step18(); // Close
};
}

// EOF

I’ve had after thought on this I was looking at using applescript studio (like the idea of compiling a window)

Ignoring this I don’t think I need it and it can be simpler.

This how I think it can work

[b]Get list of folders of folder Desktop

Exclude the folder “HotFolder”

“if the beginning of the folder name = Freed” then set as folder freeFolder if not ignore add to end log
“if the beginning of the folder name = Top” then set as folder topFolder if not ignore add to end log
“if the beginning of the folder name = Mata” then set as folder mataFolder if not ignore add to end log

Get week number from the folder name of freeFolder (this is found in the folder name after WK) set as weekNumber

Get images of folder freeFolder and run Freed.app (droplet) or maybe run each image through the photoshop, under file>scripts>freed

Then use the weekNumberFree for the input.

Once completed

Get week number from the folder name of topFolder (this is found in the folder name after WK) set as weekNumberTop

Get images of folder topFolder and run top.app (droplet) or maybe run each image through the photoshop, under file>scripts>top

Then use the weekNumbertop for the input.

And so on
[/b]

mcquiff, I can’t help but think you have gone about this in a most unusual way. There is NO logic to that code except the creation of 3 folders and passing the path to the save. The code is action manager ( the same as recording an action in photoshop ) with AppleScript & Photoshop you could just.

open file
do action from action set
save to given path

I think all the steps in that could be done with AppleScript. That apart as you have this working in JavaScript form you can instead use.
do JavaScript and pass a string of the syntax or alias to the *.jsx file.

By far the easiest way to schedule scripted tasks on the mac is to set them up as iCal events. These can trigger an AppleScript even if it is just a wrapper for you JavaScript. Bridge can do something similar but needs to be permanently running.

The Javascript/action Manager is just the code created in photoshop script. I don’t want to change that as that does a number of things. Which is save down to set of different folders across a network.

Intial step prompt for week input.

[center]step1(); // Flatten Image
step2(); // Smart Sharpen
step3(); // Save
step4(); // Select
step5(); // Image Size
step6(); // Smart Sharpen
step8(); // Select
step9(); // Select
step10(); // Select
step11(); // Delete
step12(); // Merge Visible
step13(); // Set
step13a(); // Save
step18(); // Close
[/center]

However are you saying that everything above can also be done using applescript? I assume still using photoshop?

The area in was confused with is getting the week number from the folder and then passing that on to the script and also passing the name to use the relevant script.

What I am saying is you can script Photoshop in AppleScript, Visual Basic & ExtendScript ( based on javascript 1.4 ) The object model is the same for each language. So yes this could have been written entirely in AppleScript. The fact that those steps are action manager code ( an action ) you could just play them all as I showed above. It’s only the save that would need script for the location logic. As for passing variables your main.

function Design(); // Can take arguments.

and you could use do javascript yourFile with arguments { } – Variable(s) in AppleScript list.