Copy link to clipboard
Copied
Good Morning,
We have 1000 directory.
In each directory there is one JPG and 1 or 2 or 3 PSD.
We have to paste the JPG that found in each diretory in each PSD in that directory.
Can I use batch?
sorry for my english.
thanks
Franco
Here is something you could try...
#target photoshop;
app.bringToFront();
main();
function main(){
var folders =[];
var topLevel = Folder.selectDialog("Please select top level folder");
if (topLevel == null ) return;
folders = FindAllFolders(topLevel, folders);
folders.unshift(topLevel);
for(var a in folders){
files=[]; psd=[];
files = folders[a].getFiles(/\.(jpg|tif)$/i);
if(files.length < 1) continue;
psd = folders[a].getFiles(/\.(psd)$/i);
if(psd.length < 1) continue;
...
This is a Photoshop script not automator.
Save the script as a plain text file with a .jsx extension and save it in Potoshop/Presets/Scripts folder
If Photoshop was open, restart it so that it can pick up the new script.
To use: File - Scripts - select the script and it will prompt you to select the top level folder.
Copy link to clipboard
Copied
I believe that you will need a custom script.
A lot more info will be required in order for somebody to offer a scripted solution if you can't write a script.
Does the jpg filename vary or is it static? What pixel size and or resolution is the jpg vs the psd?
I'd suggest that you attempt to find a similar script to help start this process.
Copy link to clipboard
Copied
Ok I try to give more infos.
We have 1 directory-
In these directory there are some directories.
In hìeach directorry there are 1 file (jpg or tiff) and 1 ore other PSD file.
We have to paste the jpg or tiff in the PSD file and go to the next directory with the same job (take the jpg or tiff and past in all PSD files found in directory)
Working on Mac. Latest Photoshop version.
thanks
Franco
Copy link to clipboard
Copied
I would recommend an Automator action to walk through the folders and run a Photoshop script that opened the files and pasted or placed the JPG/TIFF into the PSD.
Copy link to clipboard
Copied
Yes, I think about Automator script but i don't know nothing about scripting and programming.
I will try
In your hoppinion is not possible use photoshop automation/batch or similar?
Copy link to clipboard
Copied
An Action will not be able to walk through folders to process your files. You could look at File->Scripts->Load Files into Stack to see if that worked for you.
Copy link to clipboard
Copied
I would just use Image Processor Pro which can recurse into sub-directories under the nominated top-level folder and run an action (the action can also point to a script).
I don't see that as the main issue.
A script will need to filter the opening of the first file with a variable filename with a .jpg or .tif extension. Then this file will need to be copied, then perhaps closed.
The script will then need to iterate through the remaining files in the folder that have a .psd extension and paste from the clipboard into each .psd and save.
All of this is possible, but easier said than done.
This of course only accounts for a single folder, so further coding is required to recurse into all sub-folders.
Copy link to clipboard
Copied
Here is something you could try...
#target photoshop;
app.bringToFront();
main();
function main(){
var folders =[];
var topLevel = Folder.selectDialog("Please select top level folder");
if (topLevel == null ) return;
folders = FindAllFolders(topLevel, folders);
folders.unshift(topLevel);
for(var a in folders){
files=[]; psd=[];
files = folders[a].getFiles(/\.(jpg|tif)$/i);
if(files.length < 1) continue;
psd = folders[a].getFiles(/\.(psd)$/i);
if(psd.length < 1) continue;
for(var p in psd){
app.open(psd[p]);
placeFile(files[0]);
app.activeDocument.close(SaveOptions.SAVECHANGES);
}
}
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 placeFile(placeFile) {
var desc96 = new ActionDescriptor();
desc96.putPath( charIDToTypeID('null'), new File(placeFile) );
desc96.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var desc97 = new ActionDescriptor();
desc97.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 );
desc97.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 );
desc96.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc97 );
executeAction( charIDToTypeID('Plc '), desc96, DialogModes.NO );
};
};
Copy link to clipboard
Copied
Great job as always SuperMerlin!
I'm now embarrassed to show the hack-job that I was working on... however, if somebody is willing to offer constructive criticism and show me how to incorporate recursive processing I'm sure it would be worthwhile.
Copy link to clipboard
Copied
Thanks you very mutch for your job.
But, be patient, I don't know how to use it, I have to create a new script file in automator and past your code and then push play?
i'm so sorry.
thanks from Italy
Franco
Copy link to clipboard
Copied
This is a Photoshop script not automator.
Save the script as a plain text file with a .jsx extension and save it in Potoshop/Presets/Scripts folder
If Photoshop was open, restart it so that it can pick up the new script.
To use: File - Scripts - select the script and it will prompt you to select the top level folder.
Copy link to clipboard
Copied
Hello
thanks you very much
it works and it is very very fast
thanks you from Italy 🙂
Franco
Copy link to clipboard
Copied
You are welcome, Keep safe!
Copy link to clipboard
Copied
Further to SuperMerlin's reply on how to use the script, you can find more info here:
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Copy link to clipboard
Copied
Update: I tried my previous suggestion using both Image Processor and Image Processor Pro to play the script that I created and recorded into an action... however, the recursive processing had errors. So much for that idea!