Copy link to clipboard
Copied
Hi again 😉
Have a new request , is it possible to do this :
A script for automate creation of a list of .psd file ( from a template) from a csv file into each folders create from another .csv file ?
- Have a csv file with name for .psd (10 .psd) :
- ref_up
- ref_down
- ref_left
- ref_right
- etc..
- Have a csv file with name for folders ( could have 300 folders or more) :
- folderA
- folderB
- folder C
- etc....
what I expect to do :
create each .psd files into the folders create from a csv file :
- "folderA" with inside ref_up.psd, ref_down.psd, ref_left.psd, etc...
- "folderB" with inside ref_up.psd, ref_down.psd, ref_left.psd, etc...
etc...
I think that it could be :
Have my .psd template file open,
run the script :
where is the csv file for .psd
where is the csv file for folders
tell : where you want to create the folders
read the csv file for number of folder to create
read the csv file for number of .psd to create
while end of folder list
repeat for each name found create folder and create its .psd files
Done
Thanks again for your help, I think it could be done, otherwise it will be repetitive work to do manually and I think it could be more efficient 😉
Regards,
Christian
1 Correct answer
Hi all,
Finally I found to do it myself, it works well, but I'd like to ask you some advice :
- is it the good way how I'm writing it ?
- is there some options to add for special cases ?
- finally have a question : it read a csv file with lines, but I didn't find to run it with csv file with "," separation between list of folders, or psd names.... do you have ideas ? I try with split(",") but it didn't works.
Here is my script :
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Un
...
Explore related tutorials & articles
Copy link to clipboard
Copied
Hi all, is anybody have a tips for write the script for this ? Is is the good way, or made a loop inside a loop ?
For i = 1 to x ( where x is equal to the number of folders to create from the csv file)
do create folder named from csv file
for i= 1 to x ( where x is equal to the number of psd to create from the other csv file)
do create all the .psd named from csv file
Thanks again for your helps !
Christian
Copy link to clipboard
Copied
What are your problems so far?
The file selection, the creation of Folders, the creation of the files, …?
Copy link to clipboard
Copied
Hi, thanks for your answer !
the problem is the script writing in Java :-),
I think i have the right structure, the good organisation, but I'm a noob in script writing....
and when something's wrong, haven't enough knowledge to made it correctly....
Regards,
Christian
Copy link to clipboard
Copied
Photoshop Scripting doesn’t use Java, but JavaScript. (VB and AppleScript are also options.)
Please post the Script you have so far.
Copy link to clipboard
Copied
I try this but it just made first subfolder, then Photoshop squizz.... :
this the first step : create each subfolders from csv list (for my test, 3 subfolders : ( folder1,folder2,folder3))
var csv = File.openDialog("Please select CSV file.","CSV File:*.csv");
var TopFolder = Folder.selectDialog( "Please Select Top Folder to create subfolders");
csv.open('r'),
r = csv.read(),
csv.close(),
arr = r.split(','),
outputFolder = Folder(TopFolder + "/" + arr.shift())
while (arr.length) outputFolder.create()
Copy link to clipboard
Copied
Hi all,
Finally I found to do it myself, it works well, but I'd like to ask you some advice :
- is it the good way how I'm writing it ?
- is there some options to add for special cases ?
- finally have a question : it read a csv file with lines, but I didn't find to run it with csv file with "," separation between list of folders, or psd names.... do you have ideas ? I try with split(",") but it didn't works.
Here is my script :
var tmp = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.MM;
var csv = File.openDialog("Choose file for subfolders","CSV File:*.csv");
var psd = File.openDialog("Choose file for psd","CSV File:*.csv");
var TopFolder = Folder.selectDialog( "Please Chose Top Folder to create subfolders");
var rows = [];
var rows2 = [];
csv.open('r');
psd.open('r');
while ( !csv.eof ) {
rows[ rows.length ] = csv.readln();
}
csv.close();
while ( !psd.eof ) {
rows2[ rows2.length ] = psd.readln();
}
psd.close();
alert("Number of folders to create :"+rows.length);
alert("Number of psd to create :"+rows2.length);
var pLen = rows.length;
for(var i=0;i<pLen;i++) {
var folderName = rows[i];
alert ("I create the folder:"+folderName);
var outputFolder = Folder(TopFolder + "/" + folderName);
if(!outputFolder.exists) outputFolder.create();
var pLen2 = rows2.length;
alert("There is "+pLen2+"PSDs to create in this folder");
var curPath = outputFolder;
for(var t=0;t<pLen2;t++) {
var savePath = curPath + "/" + rows2[t] + ".psd";
app.documents.add(parseInt(8), parseInt(6));
var saveFile = new File(savePath);
alert("Here is the name of the PSD: "+saveFile);
savePSD(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
function savePSD(saveFile)
{
var saveOptions = new PhotoshopSaveOptions();
saveOptions.alphaChannels = false;
saveOptions.annotations = false;
saveOptions.embedColorProfile = true;
saveOptions.layers = true;
saveOptions.spotColors = false;
app.activeDocument.saveAs(saveFile, saveOptions, true, Extension.LOWERCASE);
}
}
//var curPath = TopFolder;
}
alert("All is done");
Thanks in advance,
Regards,
Christian

