Photoshop Scripting: How can I duplicate the document to a new file and run my export actions on the new one?
Hi, so I have many actions that will resize, edit, export, and close the document I'm currently working with. I'd like to write a Photoshop script that will duplicate the document to a new file and run all the actions that I'd normally run on the original document. I'd like it to give me a user input box that would be the name of the new document. Currently this is what I came up with last week, and it's not quite working:
var newName = prompt("Enter in a new name for the file, without the extension.", "", "New Document Name");
if (null !== newName) {
var doc = app.activeDocument;
var extension = doc.name.split('.')[1]
newName += '.' + extension;
var docName= doc.fullName;
var file = new File(docName);
file.rename (newName);
app.open(file);
docLay=app.activeDocument.layers;
l=app.activeDocument.layers.length;
while (l>0) {
l--;
docLay
.isBackgroundLayer = false; docLay
.allLocked = false; }
doc.close (SaveOptions.SAVECHANGES);
}
Basically I just want to get the new name for the new document, create that document by copying current document, and then run my actions on that new document without altering the original document. I'd also not like to deal with saving, and I only say this because I've had errors in the past trying to get this to work where it would say that the document must be saved or something, so in short I don't need any psd files associated with my workflow.
Thanks in advance for anyone who could help me!!
