7 Replies Latest reply on Mar 6, 2017 6:07 PM by laural6522894

    Rename the current active file?

    Juano Hunt

      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"


                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


                                    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?

        • 1. Re: Rename the current active file?
          Muppet Mark Level 5

          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…

          1 person found this helpful
          • 2. Re: Rename the current active file?
            Juano Hunt Level 1

            Ah, OK. Thanks for letting me know.

            • 3. Re: Rename the current active file?
              Pedro Cortez Marques Level 3

              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.

              • 4. Re: Rename the current active file?
                Level 7

                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.

                • 5. Re: Rename the current active file?
                  JJMack Most Valuable Participant

                  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.

                  • 6. Re: Rename the current active file?
                    Juano Hunt Level 1

                    Thanks Chris and JJMack for the explanation.


                    And thanks Pedro, I might try something like that.

                    • 7. Re: Rename the current active file?



                      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?