Hi everyone I need some urgent help, if possible
I have one single PSD document from where I have separate 260 different areas and save them as single jpgs.
I can pretty much cover all the steps with actions but when I come up to "saving" I have the problem that PS4 saves them all with the same name, as it uses the name of the original document...is there any trick or any script I could use to solve that. Otherwise it will lake days doing that work...
Thanks in advance!
Christine
serializing PSD export
serializing PSD export
It's hard to say if a script can be added to your action to do the saving. It's very likely that it can be.
Does your action save each section as it selects/creates it or does is save all the parts at the end of the action?
Does your action save each section as it selects/creates it or does is save all the parts at the end of the action?
serializing PSD export
Hi Mike,
the action saves each section at the time, so in between I can select the new section and run the action again...
the action saves each section at the time, so in between I can select the new section and run the action again...
serializing PSD export
This may or may not work with your action. It assumes that the first document open is the source document and gets the folder and name from that document. It then looks in that folder for files with that document name and a number suffix. If it doesn't find one it saves the active document with the source document's name and a suffix of '_001'. If it finds files that already have a suffix it saves using the source doc's name and increments the number. Note that it only has a crude error check.
Code: Select all// This script will save the active document to a folder with an incremental sufix
// Change the options below to match your needs
try{
var saveFolder = app.documents[0].path;
var saveExt = 'psd';
var saveSufixStart = '_';
var saveSufixLength = 3;
// End of user options
//==========================================
function zeroPad ( num, digit ){
var tmp = num.toString();
while (tmp.length < digit) { tmp = "0" + tmp;}
return tmp;
}
var docName = decodeURI ( app.documents[0].name );
docName = docName.match( /(.*)(\.[^\.]+)/ ) ? docName = docName.match( /(.*)(\.[^\.]+)/ ) : docName = [ docName, docName, undefined ];
var saveName = docName[ 1 ]; // activeDocument name with out ext
var files = saveFolder.getFiles( saveName + '*.' + saveExt );// get an array of files matching doc name prefix
if( files.length == 0 ) { // no file with that name so start at one
var saveNumber = 1;
}
if( files.length == 1 ) { // one file found, see if it has a sufix
var fileName = decodeURI ( files[ 0 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
if( fileName[1].match( /_(\d{3})$/ ) == null ){
var saveNumber = 1;// does not have sufix so set to one
} else{// has sufix
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
}
if( files.length > 1 ){
files.sort();
var fileName = decodeURI ( files[ files.length -1 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
var saveFile = new File( saveFolder + '/' + saveName + saveSufixStart + zeroPad( saveNumber, saveSufixLength ) + '.' + saveExt );
activeDocument.saveAs( saveFile, undefined ,true ,Extension.LOWERCASE);
}catch(e){
alert('Script error\rFile not saved');
}
Code: Select all// This script will save the active document to a folder with an incremental sufix
// Change the options below to match your needs
try{
var saveFolder = app.documents[0].path;
var saveExt = 'psd';
var saveSufixStart = '_';
var saveSufixLength = 3;
// End of user options
//==========================================
function zeroPad ( num, digit ){
var tmp = num.toString();
while (tmp.length < digit) { tmp = "0" + tmp;}
return tmp;
}
var docName = decodeURI ( app.documents[0].name );
docName = docName.match( /(.*)(\.[^\.]+)/ ) ? docName = docName.match( /(.*)(\.[^\.]+)/ ) : docName = [ docName, docName, undefined ];
var saveName = docName[ 1 ]; // activeDocument name with out ext
var files = saveFolder.getFiles( saveName + '*.' + saveExt );// get an array of files matching doc name prefix
if( files.length == 0 ) { // no file with that name so start at one
var saveNumber = 1;
}
if( files.length == 1 ) { // one file found, see if it has a sufix
var fileName = decodeURI ( files[ 0 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
if( fileName[1].match( /_(\d{3})$/ ) == null ){
var saveNumber = 1;// does not have sufix so set to one
} else{// has sufix
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
}
if( files.length > 1 ){
files.sort();
var fileName = decodeURI ( files[ files.length -1 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
var saveFile = new File( saveFolder + '/' + saveName + saveSufixStart + zeroPad( saveNumber, saveSufixLength ) + '.' + saveExt );
activeDocument.saveAs( saveFile, undefined ,true ,Extension.LOWERCASE);
}catch(e){
alert('Script error\rFile not saved');
}
serializing PSD export
Hi Mike,
this works GREAT!!! Thank you sooooo much!!!!!
I actually need to safe that "optimized for the web" resized in 70px x 40px (not proportionally)...
Is that possible to adjust on the script? Otherwise I will have to run through all the stuff twice?
Really you already made my day!
Thanks
this works GREAT!!! Thank you sooooo much!!!!!
I actually need to safe that "optimized for the web" resized in 70px x 40px (not proportionally)...
Is that possible to adjust on the script? Otherwise I will have to run through all the stuff twice?
Really you already made my day!
Thanks
serializing PSD export
sorry to bother....there is a problem with the script:
it stops saving file after the numeratio 008 (and i need it to go till 90).
can someone look into that....pleaaaaaaase
it stops saving file after the numeratio 008 (and i need it to go till 90).
can someone look into that....pleaaaaaaase
serializing PSD export
...it is actually saving...but always as 001 so it looks like h jumbs back to 001 after 008...
serializing PSD export
Try changing 'parseInt' to 'Number' where it appears in the script.
serializing PSD export
I am glad that you have it working but the script I posted does not use Number. It already uses parseInt.