PhotoshopForums.com Home
Navigate Contact FAQ Search Members
Saving multiple files/names with actions
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation
 See a User Guidelines violation? Please contact us.
Author Message

lorne17

Joined: 25 Sep 2011
Posts: 12



PostPosted: Sun Sep 25, 2011 12:31 pm    Post subject: Saving multiple files/names with actions Reply with quote

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
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Sun Sep 25, 2011 2:33 pm    Post subject: Reply with quote

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);
}
View user's profile Send private message

lorne17

Joined: 25 Sep 2011
Posts: 12



PostPosted: Sun Sep 25, 2011 3:01 pm    Post subject: Reply with quote

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
View user's profile Send private message

Paul R

Joined: 06 Apr 2010
Posts: 57



PostPosted: Sun Sep 25, 2011 3:12 pm    Post subject: Reply with quote

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.
View user's profile Send private message

lorne17

Joined: 25 Sep 2011
Posts: 12



PostPosted: Sun Sep 25, 2011 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message

thehermit

Joined: 05 Mar 2003
Posts: 3987
Location: Cheltenham, UK


PostPosted: Sun Sep 25, 2011 3:28 pm    Post subject: Reply with quote

Tips hat Pauls way, as always.
_________________
If life serves you lemons, make lemonade!
View user's profile Send private message

Patrick
Administrator
Administrator

Joined: 14 Feb 2003
Posts: 11945
Location: Harbinger, NC, U.S.A.


PostPosted: Sun Oct 02, 2011 11:18 am    Post subject: Reply with quote

Good information, Paul. Thanks.

Patrick

_________________
Patrick O'Keefe - PhotoshopForums.com Administrator
Have a suggestion or a bit of feedback relating to PhotoshopForums.com? Please contact me!
User Guidelines
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger

otineb

Joined: 13 May 2013
Posts: 1



PostPosted: Mon May 13, 2013 12:44 pm    Post subject: AMAZING Reply with quote

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..."
View user's profile Send private message

lorne17

Joined: 25 Sep 2011
Posts: 12



PostPosted: Thu Nov 05, 2015 10:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PhotoshopForums.com Forum Index -> Actions and Automation All times are GMT - 6 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Contact - User Guidelines >

Copyright © 2003-2016. PhotoshopForums.com, iFroggy Network. All Rights Reserved.
Powered by phpBB © phpBB Group. phpBB SEO. Privacy Policy.
We are in no way affiliated with Adobe. Photoshop, Adobe and related marks are registered trademarks of Adobe.
PhotoshopForums.com