Copy link to clipboard
Copied
I'd like to be able to add the indesign filename into the meta data xmp (File info/Document Title) automatically on all the documents we work on. The reason being our client changes the file name on the pdf's we send and when they return the pdf to us for amends I have little or no way of locating the file amongst 25,000 documents.
Copy link to clipboard
Copied
Copy the text between the two lines below.
Paste it into a text editor and save the file as "storeTitleXMP.jsx"
In this folder:
/Applications/Adobe InDesign CC 2014/Scripts/startup scripts/
This script will load at startup of InDesign and will run just before each time the file is saved.
When you view the RAW XML you will see the following listed within the document XMP:
" <xmp:LCCDocumentStatus>In Progress</xmp:LCCDocumentStatus>
<xmp:LCCUserName>jhaney</xmp:LCCUserName>
<xmp:LCCRevisionNotes>More edits</xmp:LCCRevisionNotes>
<xmp:InDesignFileName>Untitled-7 copy.indd</xmp:InDesignFileName>
<xmp:CreatorTool>Adobe InDesign CC 2014 (Macintosh)</xmp:CreatorTool>
"
script begins below line
-------------------------
#targetengine 'session'
var myEventListener = app.addEventListener("beforeSave", function (myEvent) {
var doc = app.documents[0];
var docTitle = (doc.name);
var myDocXMP = app.activeDocument.metadataPreferences;
var destNamespace = "http://ns.adobe.com/xap/1.0/";
var destNodeName = "InDesignFileName";
var nodeValue = docTitle;
myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);
}
).name = "storeTitleXMP";
------------------------
script ends above line
Hope this gives you what you need.
Copy link to clipboard
Copied
To access the extended metadata in Acrobat:
Open file
Choose menu "Properties"
with the "Description" tab selected
Click on the button named "Additional Metadata..."
Click on "Advanced"
Click the triangle next to "XMP Core Properties..."
Your custom field will be listed in the fields presented under this item.
Copy link to clipboard
Copied
Hi James,
If this work it will save me hours of work!! I have tried to load the scrip but I’m getting the below error message in Indesign – what do you think? Sorry to as the question but I know nothing about scripting.
Thanks
Paul
Copy link to clipboard
Copied
Hi,
What about this :
#targetengine "onBeforeOpenAndNew"
function main() {
//Referencing events
var onAfterOpenEvent = app.eventListeners.item("onAfterOpen");
var onAfterNewEvent = app.eventListeners.item("onAfterNew");
var onAfterSaveEvent = app.eventListeners.item("onAfterSave");
var onAfterSaveAsEvent = app.eventListeners.item("onAfterSaveAs");
//Adding name to description
var f = function(evt){
var doc = evt.target;
if ( !(doc instanceof Document) ) return;
var m = doc.metadataPreferences.documentTitle;
var dn = doc.name;
( m=="" || m!=dn ) && doc.metadataPreferences.documentTitle = dn;
}
//Adding listeners only is not declared yet
!onBeforeOpenEvent.isValid && app.eventListeners.add( "afterOpen", f ).name = "onAfterOpen";
!onBeforeNewEvent.isValid && app.eventListeners.add( "afterNew", f ).name = "onAfterNew";
!onAfterSaveEvent.isValid && app.eventListeners.add( "afterSave", f ).name = "onAfterSave";
!onAfterSaveAsEvent.isValid && app.eventListeners.add( "afterSaveAs", f ).name = "onAfterSaveAs";
}
//function call
main();
HTH,
Loic
Copy link to clipboard
Copied
That's strange, it works on my system. Try this version:
#targetengine "storeTitleXMP"
var myEventListener = app.addEventListener("beforeSave", function (myEvent) {
var doc = app.documents[0];
var docTitle = (doc.name);
var myDocXMP = app.activeDocument.metadataPreferences;
var destNamespace = "http://ns.adobe.com/xap/1.0/";
var destNodeName = "InDesignFileName";
var nodeValue = docTitle;
myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);
}
).name = "storeTitleXMP";
Copy link to clipboard
Copied
Okay still having the same error…
I have created a .txt document and pasted in;
#targetengine "storeTitleXMP"
var myEventListener = app.addEventListener("beforeSave", function (myEvent) {
var doc = app.documents[0];
var docTitle = (doc.name);
var myDocXMP = app.activeDocument.metadataPreferences;
var destNamespace = "http://ns.adobe.com/xap/1.0/";
var destNodeName = "InDesignFileName";
var nodeValue = docTitle;
myDocXMP.setProperty(destNamespace, destNodeName, nodeValue);
}
).name = "storeTitleXMP";
Then saved the file naming it; storeTitleXMP.jsx and moved the file to the startup scripts in Indesign.
Is this correct??
Thanks again
Copy link to clipboard
Copied
I just followed the instructions just as you described them (copying the script directly from you comment above) and it worked fine for me.
It may be that you are storing the text file in rich text format.
give me your email and I will send you the script as a plain text file.
Copy link to clipboard
Copied
Hi James,
It’s pcollins@redtagdm.co.uk
Thanks
Paul
Copy link to clipboard
Copied
Hi Paul
Found this thread and wondered if you and James found a resolution for this.
I tried the above but I appeared to experience the same issues as you did.
Be good to know if you solved it
Ta
Jo
Copy link to clipboard
Copied
Please use NOTEPAD or similar text editor.
save the file as .jsx
Copy link to clipboard
Copied
thanks Vamitul
Copy link to clipboard
Copied
Hi all,
I want to adjust this script so it saves the INDD name to the PDF 'Subject', not title. What needs to change?
Copy link to clipboard
Copied
Hi James,
I want to adjust this script so it saves the INDD name to the PDF 'Subject' (or keywords, copyright... anything really), not title. What needs to change?
Copy link to clipboard
Copied
Above script replace the title with file naming, can you please re-edit the script through which only author name can be customize.
Copy link to clipboard
Copied
I've tried this in Indesign 18.2.1 and it doesn't work. Does anyone have an updated script to add Indesign filename into Document Title and the author into author field. I know nothing about scripting but as others have said, clients change the filename of pdfs all the time, so embedding this info into the indesign doc before export would be super helpful.