• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Rename the current active file?

Community Beginner ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

I'm wanting a script to be able to rename open Photoshop files, if possible.

I cobbled this together from an existing script:

tell application "Adobe Photoshop CS5"

  activate

          set old_name to name of current document

          set dialog_result to display dialog ¬

                    "Rename active document:" default answer (old_name) ¬

                    buttons {"Cancel", "Rename"} default button 2 ¬

  with icon note

          if button returned of dialog_result = "Rename" then

                    set new_name to text returned of dialog_result

                    set d to properties of current document

                    if path of d is equal to missing value then

                              set name of current document to new_name

                    else

                              tell me to set the_file to POSIX file (d's path as text) as alias

                              tell application "Finder"

                                        set name of the_file to new_name

                              end tell

                    end if

          end if

end tell

If I run it it shows the dialogue window, but when I enter the new name and hit Return it throws out lots of errors.

Is something like this possible?

TOPICS
Actions and scripting

Views

20.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

Because name is a read only property… Either re-name files using your system or as part of a save as but not just with an open document… It not going to work…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

Ah, OK. Thanks for letting me know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2017 Mar 06, 2017

Copy link to clipboard

Copied

LATEST

Hello,

I am using a form in Adobe and would like to open a form like called Blank #1 and fill it in and save as John Doe.And then open the Blank #1 fill it in and call it Jane Doe (or even open Jane Doe and edit it and call it John Doe.) But I don't see how to change the name of the file after I change/add information. There is only a Done option that saves it as the original name of the document. Is this not possible?

Laura

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

Have you tried to "duplicate" the active document with the new name and close the old one? Its kind of work-arround the problem, but it might work the same.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

There is no "active file" -- documents in Photoshop are not necessarily related to a file on disk.

And you can always save them to a different name/path.

"Save As" is the only good way to change the association of a document with a file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2011 Sep 28, 2011

Copy link to clipboard

Copied

As Chris wrote Photoshop is not a File Editor. Photoshop edits Photoshop Documents the current Document may or may not have a file on the system created fron the active document.  If if does have a file assocatation I sure with scripting you can perform file operations on the file  like delete, rename, move etc.  However the will not change the active document name. Basicly document name is read only.... well sort of read only for if the current document does not have a file assocation and you save it into you file system The docoument becomes assocated with a file and Photoshop will change the active document name.  Aslo when you open a RAW file through ACR the inage image window or tab may show something like imagename.cr2 there is not actually a file associated with the document for Photoshop can not save a Camera RAW file so if you save it as PSD or TiFF the window or tab will now show the file assocation imagename.psd|tif  not .cr2. The document name does not always change with a save for if you save the PSD as a jpeg after the jpeg images is saved the document reverts back to its layered and color depth state  and is still imagename.psd.  There is no active document associated with that saved jpeg file. You can open it and have two document open that look the same one being layered a and perhaps 16bit and the other flat and 8bit.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 29, 2011 Sep 29, 2011

Copy link to clipboard

Copied

Thanks Chris and JJMack for the explanation.

And thanks Pedro, I might try something like that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines