Copy link to clipboard
Copied
What I am after is a script (for mac) that will enter the user name in the Author field of the File Information.
If the script could dynamically pick up the user name, that would be useful, but not essential. The main thing is it would need to run on save as I cannot rely on people to remember to enter the details themselves.
Any help hugely appreciated
Carl
Copy link to clipboard
Copied
Hi,
If you place a script into user "Startup Scripts" folder
and
if your script will define an eventListener (type "afterSave")
==> it could be done.
Example:
#target indesign
#targetengine "session"
var
myEventListener = app.eventListeners.item("mAfSave");
if (!myEventListener.isValid) {
myEventListener = app.addEventListener( "afterSave", doJob );
myEventListener.name = "mAfSave";
}
function doJob() {
if (!app.documents.length) return;
var myDoc = app.activeDocument;
myDoc.metadataPreferences.author = app.userName; // Win or Mac app user
//~ myDoc.metadataPreferences.author = $.getenv("USERNAME"); // Windows logged user
//~ myDoc.metadataPreferences.author = $.getenv("USER"); // MAC logged user
}
Jarek
Copy link to clipboard
Copied
Thanks,
That seems to kind of work... But now my ⌘S command is not working and when I manually save the file (using the File Menu) the Title bar of the doc doesn't recognise the save and still gives the "Save Changes" dialogue box when you close.
Also, just realised it really messes around when adding files to a Book!
Any ideas? I don't really know about coding so I really appreciate the help.
Carl
Copy link to clipboard
Copied
Hi,
1. No idea what you mean by "⌘S command is not working".
2. If your goal is to edit file (modify file info) after save ==> file has some changes (unsaved) right?
3. Maybe changing eventListener type to "beforeSave" could help?
Jarek
Copy link to clipboard
Copied
NAILED IT!
Thanks Jarek!
Carl
Find more inspiration, events, and resources on the new Adobe Community
Explore Now