Indesign filename into the meta data automatically

Community Beginner ,
Mar 27, 2015 Mar 27, 2015

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.

TOPICS
Scripting

Views

1.9K

Likes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2015 Mar 30, 2015

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.

Likes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2015 Mar 30, 2015

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.

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2015 Mar 31, 2015

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

Screen Grab.jpg

Likes

Translate

Translate

Report

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
Valorous Hero ,
Mar 31, 2015 Mar 31, 2015

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

http://www.ozalto.com

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2015 Mar 31, 2015

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";

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2015 Mar 31, 2015

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

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2015 Mar 31, 2015

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.

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2015 Mar 31, 2015

Copy link to clipboard

Copied

Hi James,

It’s pcollins@redtagdm.co.uk

Thanks

Paul

Likes

Translate

Translate

Report

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
New Here ,
Jan 11, 2017 Jan 11, 2017

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

Likes

Translate

Translate

Report

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
Advisor ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Please use NOTEPAD or similar text editor.
save the file as .jsx

Likes

Translate

Translate

Report

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
New Here ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

thanks Vamitul

Likes

Translate

Translate

Report

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
Explorer ,
Feb 09, 2021 Feb 09, 2021

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?

Likes

Translate

Translate

Report

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
Explorer ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

LATEST

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?

Likes

Translate

Translate

Report

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