|
Author |
Message |
lorne17
Joined: 25 Sep 2011
Posts: 12
|
Posted: Sun Sep 25, 2011 12:31 pm Post subject: Saving multiple files/names with actions |
|
|
Hello there,
I have some actions setup to create a t-shirt mockup for my t-shirt designs. What I am needed the script to do is to save a "save to web" file for every color t-shirt available. Is it possible to append the current layer name to the end of the file name so the files are original and don't overwrite each other. I don't want to have to type in the file name with each save, I'm looking to get it automated.
I hope this makes sense. Let me know if anyone can help. Thanks so much,
Lorne |
|
|
|
|
Paul R
Joined: 06 Apr 2010
Posts: 57
|
Posted: Sun Sep 25, 2011 2:33 pm Post subject: |
|
|
Something like this?
Code: |
#target photoshop
main();
function main(){
if(!documents.length) return;
try{
var Path= activeDocument.path;
}catch(e){var Path = "~/desktop";}
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_");
var saveFile= new File(Path + "/" + Name + "-" + layerName + ".jpg");
SaveForWeb(saveFile,80);
}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = jpegQuality;
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}
|
|
|
|
|
|
lorne17
Joined: 25 Sep 2011
Posts: 12
|
Posted: Sun Sep 25, 2011 3:01 pm Post subject: |
|
|
Paul,
Thanks for the reply, however I'm new at this photoshop scripting thing. Would this be a script outside of photoshop? Or just using the actions panel?
Thanks
Lorne |
|
|
|
|
Paul R
Joined: 06 Apr 2010
Posts: 57
|
Posted: Sun Sep 25, 2011 3:12 pm Post subject: |
|
|
Copy and paste the script into ExtendScript Toolkit (ESTK), this gets installed with Photoshop
and is the integrated development environment (IDE).
This utility can be found in the relevant folder:-
PC: C:\Program Files\Adobe\Adobe Utilities
MAC: <hard drive>/Applications/Utilities/Adobe Utilities
If you are using windows Vista/Windows 7 you will need to save the script somewhere you will access (DeskTop will do)
Then copy the script to:
PC: C:\Program Files\Adobe\Adobe Photoshop CS#\Presets\Scripts
MAC: <hard drive>/Applications/Adobe Photoshop CS#/Presets/Scripts
# being the CS version
If Photoshop was open close and restart it so that it can pick up the new script.
You can use the script as part of your action as it can record the actions of:
File - Scripts - select the script
This will save the document as a jpg to the same location as the original document.
Hope this helps. |
|
|
|
|
lorne17
Joined: 25 Sep 2011
Posts: 12
|
Posted: Sun Sep 25, 2011 3:21 pm Post subject: |
|
|
Awesome, that worked and I assigned a keyboard shortcut to it, so now I can add that to my actions as a script move and viola! It is saved! Man I love automation.
Thank so much!
Lorne |
|
|
|
|
thehermit
Joined: 05 Mar 2003
Posts: 3987
Location: Cheltenham, UK
|
Posted: Sun Sep 25, 2011 3:28 pm Post subject: |
|
|
Tips hat Pauls way, as always. _________________ If life serves you lemons, make lemonade! |
|
|
|
|
Patrick
Administrator
Joined: 14 Feb 2003
Posts: 11945
Location: Harbinger, NC, U.S.A.
|
Posted: Sun Oct 02, 2011 11:18 am Post subject: |
|
|
|
|
|
|
|
otineb
Joined: 13 May 2013
Posts: 1
|
Posted: Mon May 13, 2013 12:44 pm Post subject: AMAZING |
|
|
THIS IS INCREDIBLE!
This is almost exactly what I need too.
I'm using a smart object with multiple layers within it. This causes my filenames to be exactly the same each time.
Is there a way for it to append a unique number to the end of the filename if it finds one with the exact same filename in the destination folder?
Like: "File, File_1, File_2, File_3, ect..." |
|
|
|
|
lorne17
Joined: 25 Sep 2011
Posts: 12
|
Posted: Thu Nov 05, 2015 10:35 am Post subject: |
|
|
Hey Paul,
I'm going to dig this one up from a long time ago! I'm redesigning my tshirt website and I wanted to make these images of mockups a transparent background.
How might I go about editing this actionscript to have it export the file as a transparent PNG saved for web and append the layer name at end of file name? Like before, just changing from jpg to png?
thank you!
Original Code you so generously shared:
Code: | #target photoshop
main();
function main(){
if(!documents.length) return;
try{
var Path= activeDocument.path;
}catch(e){var Path = "~/desktop";}
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_");
var saveFile= new File(Path + "/" + Name + "-" + layerName + ".jpg");
SaveForWeb(saveFile,80);
}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = jpegQuality;
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
} |
Thanks,
Lorne |
|
|
|
|
|