Copy link to clipboard
Copied
Is there anyway to change a document's name? Or create a document with a certain name?
I'm looking at the JavaScript reference, and it says that document.name is a readonly value. Is this entirely true / is there any other way to change the name of a document?
Any help would be much appreciated
Thanks!
You can change the name of a document in two ways:
1. Open it, save it under a different name, and delete the original.
2. Don't open the document, use JavaScirpt's File object to rename the document. Details can be found in the JavaScript Tools Guide, accessed from your ESTK in the Help menu.
Peter
Copy link to clipboard
Copied
app.documents.add ([showingWindow: bool=true][, documentPreset: DocumentPreset][, withProperties: Object])
the main interest for you is the "withProperties" part.
Copy link to clipboard
Copied
I'm new to javascript so bear with me :c
I don't fully understand the type Object. Since there is no specific reference for withProperties, I don't get how I would insert the parameters I need into a variable of the type "Object"
Is there somewhere I can see this?
Copy link to clipboard
Copied
ok.. my mistake. i just tried it and it doesn't work.
Apparently the ony way to chage the name of the document is by saving it with (another) filename
var d=app.documents.add(false);
d.save("d:\mytestdoc.indd");
alert(d.name);
Copy link to clipboard
Copied
You can change the name of a document in two ways:
1. Open it, save it under a different name, and delete the original.
2. Don't open the document, use JavaScirpt's File object to rename the document. Details can be found in the JavaScript Tools Guide, accessed from your ESTK in the Help menu.
Peter
Copy link to clipboard
Copied
Hi Alex,
Use this...
myDocument = app.activeDocument;
path = myDocument.fullName;
alert(path);
var x = path.toString().replace("oldName", "NewName");
//OldName is ur file's name. newName is the name u want to save it.
myDocument.save(File(x));
With Regards,
Vel.