Wow!
You managed to cut down a lot of the gibberish in it too.
I ran it and it ran as it should.
The only thing that I did find that when I deleted the folders and emptied the trash. And then ran the code again it would never ask for the week number. Only as you mentioned by holding the alt key. Is there any way round this?
Many Thanks much appreciated.
Matt
Create folders with input prompt.
Create folders with input prompt.
Sorry I should mention when holding the Alt it also leaves behind an Mikey_WKnull_HR and Mikey_WKnull_LR folder.
anyway this can be removed?
anyway this can be removed?
Create folders with input prompt.
It seems that when I modified the script I moved the code that checks if the user canceled the prompt so that it now creates the folder and saves the files even if the user does cancels. I can fix that but before I do I have some questions.
1. What do you want to happen if the user does cancel the prompt? Should it do nothing or use some default string? If it should use a default string what do you want that to be?
2. I don't understand when you want the prompt. I set it up so that it would not prompt unless you needed to change the string and you do that by using the alt key. When do you want a prompt and when do you not?
1. What do you want to happen if the user does cancel the prompt? Should it do nothing or use some default string? If it should use a default string what do you want that to be?
2. I don't understand when you want the prompt. I set it up so that it would not prompt unless you needed to change the string and you do that by using the alt key. When do you want a prompt and when do you not?
Create folders with input prompt.
1/when they cancel the prompt it would do nothing just end the script there.
2/ When I automate the action in photoshop I would want the prompt to come up then as soon as it begins asking for the week number. Then once its asked it won't need to ask again. unless i start the action myself.
I hope I have understood you correctly.
Many Thanks
Matt
2/ When I automate the action in photoshop I would want the prompt to come up then as soon as it begins asking for the week number. Then once its asked it won't need to ask again. unless i start the action myself.
I hope I have understood you correctly.
Many Thanks
Matt
Create folders with input prompt.
I don't think there is a way to have the script run from an action in batch mode where it only prompts for the first image. The script below will prompt if there isn't a saved string(first run on a system), if the alt key is held down when either running from the scripts menu or an action, or is the dialog icon is set in the actions panel. However if the dialog icon is set it will prompt with every image.
Code: Select all#target photoshop
//
// MIKEY2.jsx
//
MIKEY();
function MIKEY() {
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('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 highResFolder = new Folder('~/Desktop/Mikey_WK'+userInput+"_HR");
if(!highResFolder.exists) highResFolder.create();
var lowResFolder = new Folder('~/Desktop/Mikey_WK'+userInput+"_LR");
if(!lowResFolder.exists) lowResFolder.create();
var saveName = decodeURI(app.activeDocument.name);
saveName.match(/(.*)(\.[^\.]+)/) ? saveName = saveName.match(/(.*)(\.[^\.]+)/):saveName = [saveName, saveName];
saveName = saveName[1];
app.activeDocument.flatten();
smartSharpen(164, 0.9, 0, 50, 1, 0, 50, 1);
saveJPEG(highResFolder+'/'+saveName+'.jpg', 12, true);
stepBackHistory();
app.activeDocument.resizeImage (new UnitValue(1020,'px'), undefined, undefined, ResampleMethod.BICUBICSHARPER);
smartSharpen(180, 0.9, 0, 50, 1, 0, 50, 1);
saveJPEG(lowResFolder+'/'+saveName+'.jpg', 12, true);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
};
function smartSharpen(amount,radius,shadowFade,shadowWidth,shadowRadius,highlightFade,highlightWidth,highlightRadius) {
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), amount);
desc1.putUnitDouble(charIDToTypeID('Rds '), charIDToTypeID('#Pxl'), radius);
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'), shadowFade);
desc2.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), shadowWidth);
desc2.putInteger(charIDToTypeID('Rds '), shadowRadius);
desc1.putObject(charIDToTypeID('sdwM'), stringIDToTypeID("adaptCorrectTones"), desc2);
var desc3 = new ActionDescriptor();
desc3.putUnitDouble(charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), highlightFade);
desc3.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), highlightWidth);
desc3.putInteger(charIDToTypeID('Rds '), highlightRadius);
desc1.putObject(charIDToTypeID('hglM'), stringIDToTypeID("adaptCorrectTones"), desc3);
executeAction(stringIDToTypeID('smartSharpen'), desc1, DialogModes.NO);
};
function saveJPEG(inFileName, inQuality, inEmbedICC) {
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = inQuality;
jpegOptions.embedColorProfile = inEmbedICC;
app.activeDocument.saveAs( File( inFileName ), jpegOptions );
};
function stepBackHistory() {
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, DialogModes.NO);
};
// EOF
Code: Select all#target photoshop
//
// MIKEY2.jsx
//
MIKEY();
function MIKEY() {
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('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 highResFolder = new Folder('~/Desktop/Mikey_WK'+userInput+"_HR");
if(!highResFolder.exists) highResFolder.create();
var lowResFolder = new Folder('~/Desktop/Mikey_WK'+userInput+"_LR");
if(!lowResFolder.exists) lowResFolder.create();
var saveName = decodeURI(app.activeDocument.name);
saveName.match(/(.*)(\.[^\.]+)/) ? saveName = saveName.match(/(.*)(\.[^\.]+)/):saveName = [saveName, saveName];
saveName = saveName[1];
app.activeDocument.flatten();
smartSharpen(164, 0.9, 0, 50, 1, 0, 50, 1);
saveJPEG(highResFolder+'/'+saveName+'.jpg', 12, true);
stepBackHistory();
app.activeDocument.resizeImage (new UnitValue(1020,'px'), undefined, undefined, ResampleMethod.BICUBICSHARPER);
smartSharpen(180, 0.9, 0, 50, 1, 0, 50, 1);
saveJPEG(lowResFolder+'/'+saveName+'.jpg', 12, true);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
};
function smartSharpen(amount,radius,shadowFade,shadowWidth,shadowRadius,highlightFade,highlightWidth,highlightRadius) {
var desc1 = new ActionDescriptor();
desc1.putUnitDouble(charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), amount);
desc1.putUnitDouble(charIDToTypeID('Rds '), charIDToTypeID('#Pxl'), radius);
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'), shadowFade);
desc2.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), shadowWidth);
desc2.putInteger(charIDToTypeID('Rds '), shadowRadius);
desc1.putObject(charIDToTypeID('sdwM'), stringIDToTypeID("adaptCorrectTones"), desc2);
var desc3 = new ActionDescriptor();
desc3.putUnitDouble(charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), highlightFade);
desc3.putUnitDouble(charIDToTypeID('Wdth'), charIDToTypeID('#Prc'), highlightWidth);
desc3.putInteger(charIDToTypeID('Rds '), highlightRadius);
desc1.putObject(charIDToTypeID('hglM'), stringIDToTypeID("adaptCorrectTones"), desc3);
executeAction(stringIDToTypeID('smartSharpen'), desc1, DialogModes.NO);
};
function saveJPEG(inFileName, inQuality, inEmbedICC) {
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = inQuality;
jpegOptions.embedColorProfile = inEmbedICC;
app.activeDocument.saveAs( File( inFileName ), jpegOptions );
};
function stepBackHistory() {
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, DialogModes.NO);
};
// EOF
Create folders with input prompt.
I couldn't see that last script worked any different. Nonetheless I can work with the alt key being pressed, not to difficult to remember,
I thought i'd re iterate my process so that my work flow is clearer.
PSD Files in Folder MikeyDone
⇓
PS>File>Automate>Batch
⇓
Select Mikey Batch (I have created a action that selects the menu item script that you created)
Then
Prompts for week Number
⇓
Runs the action mentioned, by then flattening and sharpening images into to folders using the week number created.
Then the next time I would run the batch I would want the week number to be asked. (currently I then hold the alt key on the beginning of the batch)
My hopes after this stage is then to send an automated email to send out a link of the file location.
Matt
I thought i'd re iterate my process so that my work flow is clearer.
PSD Files in Folder MikeyDone
⇓
PS>File>Automate>Batch
⇓
Select Mikey Batch (I have created a action that selects the menu item script that you created)
Then
Prompts for week Number
⇓
Runs the action mentioned, by then flattening and sharpening images into to folders using the week number created.
Then the next time I would run the batch I would want the week number to be asked. (currently I then hold the alt key on the beginning of the batch)
My hopes after this stage is then to send an automated email to send out a link of the file location.
Matt