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

Renaming active document without saving

Explorer ,
Oct 07, 2022 Oct 07, 2022

I'm looking for a way to rename your active document's name without saving it.

Sounds mundane, but with some other scripts I have in my workflow, this could help smooth some stuff out.

 

I looked for a native solution in the application and couldn't find it. I took a jab at it and this is what I've come up with. 

 

var doc = activeDocument;
var docName = jobNumber3;
    
     //Active Job Name Ringer
    var jobNumber = doc.name.replace(".ai", "");
    var jobNumber2 = jobNumber.replace(".pdf","");
    var jobNumber3 = jobNumber2.replace(".eps","");

//alert(jobNumber3)

var win = new Window("dialog")
    win.text = "Document Renamer"
    win.size = [375,100]
    win.orientation = "column";

    var changeArea = win.add("group"); 
        changeArea.orientation = "row"
        changeArea.add("statictext", undefined, "Change document name");
        var newDocName = changeArea.add("edittext", undefined, jobNumber3)
        newDocName.size = [125,30]

    var buttonGroup = win.add("group");
    var okayButton = buttonGroup.add("button", undefined, "Okay")
        okayButton.onClick = function() {
            alert(jobNumber3)
            alert(newDocName.text)
            doc.name.????????? = newDocName.text;
            win.close();
            }
    var cancelButton = buttonGroup.add("button", undefined, "Cancel")
        cancelButton.onClick = function() {
            win.close()};
 win.show()

 

At this point, I'm questioning if it's even possible without saving the document.
Any assistance is appreciated!

 

TOPICS
Scripting
338
Translate
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
Community Expert ,
Oct 07, 2022 Oct 07, 2022

You can't rename an open file. Your operating system will prevent it. What you CAN do is utilize the Save A Copy function, which allows you to save as a new name without affecting your open document. Of course, you then have two documents. But this should be scriptable.

Translate
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 ,
Oct 07, 2022 Oct 07, 2022
LATEST

What's the purpose? wouldn't you need to save the document down the road?

Translate
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