Hey there,
while being modestly good at scripting in After Effects and 3DS Max, I´m a relative newbie to Photoshop scripting. Currently I´m setting up a simple pipeline to process 250 turntable photo sets. I´ve come pretty far by using Paul Rigotts "Run Action" script and combining it with my action snippets.
This is a truely great script by the way and it has helped me to automate all my tasks except one:
I have a folder with a set of subfolders in it. Inside each subfolder are a set of jpg images. I need a batch process, which goes through each of the subfolders and creates a PSD with all of the images inside it and names the PSD with the subfolder name. The image resolution of the images can be used , or the PSD can be created with the following settings: 4096x4096 px, RBG color space, 72 dpi.
While this may be done with "Load from stack" for a single file I will need this batch process to run over night for all 250 image sets.
Can somebody point me in the right direction, as I am having a hard time setting this up on my own. Maybe something like this has already been written and I just have overlooked it in my forum searches.
Thank you and best regards
Dunkelzahn
Batch Creation PSD files from images
Re: Batch Creation PSD files from images
I have this exact situation! I tried searching online and actually found this page here:
But whenever I tried running it in Photoshop (CS6 and CC2015) it throws an error of
But whenever I tried running it in Photoshop (CS6 and CC2015) it throws an error of
II'm pretty novice with JS myself too, so I actually don't know how to handle this and would appreciate any help a lot!TypeError: Undefined is not an object
Re: Batch Creation PSD files from images
Try this...
Code: Select all
#target photoshop;
app.bringToFront();
main();
function main(){
try{
var folders =[];
var topLevel = Folder.selectDialog("Please select top level folder");
folders = FindAllFolders(topLevel, folders);
folders.unshift(topLevel);
for(var f in folders){
var fileList =folders[f].getFiles(/\.(jpg)$/i);
if(fileList.length < 1) continue;
stackFiles(fileList);
var saveFile = File( decodeURI(folders[f]) + "/" + decodeURI(folders[f].name) + ".psd");
SavePSD(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}catch(e){$.writeln(e + "\n" + e.line);}
};
function FindAllFolders( srcFolderStr, destArray) {
var fileFolderArray = Folder( srcFolderStr ).getFiles();
for ( var i = 0; i < fileFolderArray.length; i++ ) {
var fileFoldObj = fileFolderArray[i];
if ( fileFoldObj instanceof File ) {} else {
destArray.push( Folder(fileFoldObj) );
FindAllFolders( fileFoldObj.toString(), destArray );
}
}
return destArray;
};
function stackFiles(files){
try{
var loadLayersFromScript = true;
$.evalFile(app.path + "/" + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/Load Files into Stack.jsx");
loadLayers.intoStack(files);
}catch(e){$.writeln(e + "\n" + e.line);}
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
};
Re: Batch Creation PSD files from images
Thanks a lot for your help! It didn't work the first time though, so I thought I'd look at the extensions and found only JPG. By adding my desired extensions to that line it worked! Something like this:Geoff wrote: ↑Wed Apr 29, 2020 10:58 am Try this...Code: Select all
#target photoshop; app.bringToFront(); main(); function main(){ try{ var folders =[]; var topLevel = Folder.selectDialog("Please select top level folder"); folders = FindAllFolders(topLevel, folders); folders.unshift(topLevel); for(var f in folders){ var fileList =folders[f].getFiles(/\.(jpg)$/i); if(fileList.length < 1) continue; stackFiles(fileList); var saveFile = File( decodeURI(folders[f]) + "/" + decodeURI(folders[f].name) + ".psd"); SavePSD(saveFile); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } }catch(e){$.writeln(e + "\n" + e.line);} }; function FindAllFolders( srcFolderStr, destArray) { var fileFolderArray = Folder( srcFolderStr ).getFiles(); for ( var i = 0; i < fileFolderArray.length; i++ ) { var fileFoldObj = fileFolderArray[i]; if ( fileFoldObj instanceof File ) {} else { destArray.push( Folder(fileFoldObj) ); FindAllFolders( fileFoldObj.toString(), destArray ); } } return destArray; }; function stackFiles(files){ try{ var loadLayersFromScript = true; $.evalFile(app.path + "/" + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/Load Files into Stack.jsx"); loadLayers.intoStack(files); }catch(e){$.writeln(e + "\n" + e.line);} }; function SavePSD(saveFile){ psdSaveOptions = new PhotoshopSaveOptions(); psdSaveOptions.embedColorProfile = true; psdSaveOptions.alphaChannels = true; activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE); };
Code: Select all
var fileList =folders[f].getFiles(/\.(jpg|png|tiff|tga)$/i);
Any idea why?
-
- Posts: 2
- Joined: Mon Apr 27, 2020 11:03 am
Re: Batch Creation PSD files from images
Wow, thank you very much, Jeff.
Just did a test with a dummy setup..works like a charm. You even thought about closing the files after saving them.
Thumbs up to you and thank you again
Just did a test with a dummy setup..works like a charm. You even thought about closing the files after saving them.
Thumbs up to you and thank you again

Last edited by Dunkelzahn on Wed Apr 29, 2020 3:42 pm, edited 2 times in total.
Re: Batch Creation PSD files from images
Wow, seems that I missed that each folder is saved into a separate PSD! Brilliant. Thanks Jeff and thanks OP for bringing that up in the first place!