Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
What's the purpose? wouldn't you need to save the document down the road?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now