Right now this one makes a duplicate of the original document with the document name like I want, but I would rather just rename the original document instead of making a duplicate.
But if the file is currently open I doubt using that is a great idea.
Most likely if the document has an assoiated file you can save the current document using "save();" to insure any updates get written out then you can rename the associated file with the name you want. Close the current document and open the renamed document.
Some of Photoshop Document Properties objects are read only for example:
fullName File Read-only. The full path name of the document.
name string Read-only. The document's name.
path File Read-only. The path to the document.
Here is what I'm trying to do just to clarify a bit better.
1 Open Document
2 Duplicate document via script to remove COPY at end of filename.
3 Close original document
4. Run action to make the duplicated copy B&W and change the background layer name to BW
5. Run script to change the name of document to "Document Name + activeLayerName
I get that far but I can't figure out how to return back to Photoshop with the documents replacement name. The only thing I can do is to make a new document with the new name but that's not what I need. Since the duplicated file hasn't been saved as yet I thought replacing the document name would be simple.
Thanks for any help!
Because the document is a new document a that was created as a dup of some othere document there is no File assocated with this new document. When you created the document you could have named it anything you wanted. Also because the is no file associated with this document I beleive that if you save the document with the name you want that Photoshop will basicly rename the document to match the file it is now associated with. I think this is something that Photoshop does when a document with no file assocation gets assocated with a file. For example if I open one of my Camera RAW file through ACR into Photoshop the name in the image window title will be RAW_FILENAME.CR2 while it looks like there is a file assocation the document does not have a file assocation for Photoshop can not write CR2 raw file. The document just needed a name so Photoshop gave it the raw file fame. Now if I save that Document as xxx.tif Photoshop will save the xxx.tif file and change the document name from RAW_FILENAME.CR2 to xxx.tif and you will see the in the image window title. While the Document name object is read only to scripts its not read only to Photoshop when there is no file assocation. Once there is a file assocation the document name is set and is read only to Photoshop now too. Even if the document had a lot of changes and I go to the history Palette and see the RAW_FILENAME.CR2 snap shot followed by the open and history. If I step back to the open the name remains xxx.tif.
So if there is no assocated file all you need do is to save the document to the filename you want the document to have and Photoshop will rename the document for you if the document truly had never been saved and has no file assocated with it.
Thanks for the info. I just can't find the correct coding to replace the document name that the currently open document has (not the original document) with the new name that I create in the script? I would think it would some kind of REPLACE command.
saveAs (saveIn [, options] [, asCopy] [, extensionType])
savein is the file your saving the document to the document should then be associated with that file and Photoshop should rename the document to match if the document had no file associated before.
Thanks, but I do not want to save it right away in case I need to do more adjustments, I just want to replace the name . How can I do that in the script?
As I wrote "When you created the document you could have named it anything you wanted" Photoshop will generate a default name of "Original Doc Name Copy" however you can override that name during the dupe operation if not with DOM code you can use scriptlistener code for the action manager. DOM code would be "duplicate ([name ] [, mergeLayersOnly] );"
Thanks, I got it to do what I needed using your suggestions.