• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Document.MetadataPreferences.creator string values for all application versions

Community Beginner ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hello there!

I'm looking for a reference of all possible values for a Document.MetadataPreferences.creator.

What I want to do in my script is to target specific InDesign versions and skip the others, but to do that I need to know a specific string values. 

E.g. one of such value is: 'Adobe InDesign CC 13.1 (Windows)'.

 

I'd be super grateful if anyone knows where to find it!

Thanks a lot!

TOPICS
Scripting

Views

262

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

correct answers 1 Correct answer

Community Beginner , Oct 27, 2020 Oct 27, 2020

Exactly, that's what I learnt as well and instead of targeting versions I test if document can be opened at all and catch the error - that's how higher versions are excluded. Lower versions are checked when allowedVersions is compared to docVersion:

 

/**
here I have paths generated from Powershell (I need to use it to get all indd files recursively from all folders and all possible nested subfolders)
*/
var pathsArray = [...]

for (var i = 0; i < pathsArray.length; i++) {
 // prevent open error t
...

Votes

Translate

Translate
Community Expert ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Go by version number, not string values. app.version returns the active version's number in the format xx.x.x.xxx. E.g. InDesign 2020 returns 15.x.x.xxx, and to get the main version number you do parseInt (app.version), which returns 15. InDesign 2019 returns 14, etc.

 

P.

Votes

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 ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Thanks Peter, I think was not specific enough, but in my case your solution won't work, because I loop through documents and need to check document versions. The app version is here unfortunately of no use for me.

 

Another problem I had was that script crushed whenever trying to open the doc created with higher InD version. Cos there is no way to check doc version befor it is actually opened, here is the way I found to make it work:

/**
here I have paths generated from Powershell (I need to use it to get all indd files recursively from all folders and all possible nested subfolders)
*/
var pathsArray = [...]

for (var i = 0; i < pathsArray.length; i++) {
 // prevent open error to crush the script
 try {
  app.open(File(pathsArray[i]));
 } catch (err) {
  // save err info to log
  log(err)
 }
 // ... proceed with the script 
 var myDoc = app.activeDocument;
 var docVersion = myDoc.metadataPreferences.creator;

 // now I need to perform some actions depending on what is a doc version 
 var allowedVersion = 'Adobe InDesign CC 14.0 (Windows)';
 var isHigherVersion = /15|16/g.test(docVersion);
 
 // ... proceed some actions
 if (allowedVersion || !isHigherVersion) {
 // ... some actions
 } else {
 // ... log some info
 }
}

 

Votes

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 ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hello Jaeck,

Try this....the MetadataPreference property you're looking to target is the "creator".

var doc = app.documents[0];
var myMetaData = doc.metadataPreferences;
myInDesignVersion = myMetaData.creator
alert(myInDesignVersion)

 

Regards,

Mike

 

Votes

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 ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hi Mike, thanks but this is something I already posted in original question. 

The question is rather to know beforehand what are the possible strings I could get, i.e. all historical InD versions that metadataPreferences.creator would return.

Votes

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 Expert ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

The documentation states that this value is a read-only string but does not list the possible values that it can have. I checked the C++ SDK as well and it also defines it just a typedef for a string value, so we are out of luck I suppose. I think the only way to know is to check it by running the script. 

-Manan

Votes

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 Expert ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

-Why woiuld you want to know which version the document was created in? If the document was created in a newer InDesign version than your app, you can't open it. If it was created in an older version you can open it, and then InDesign converts the document to your version so that in effect it's not an older-version document.

Votes

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 ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Exactly, that's what I learnt as well and instead of targeting versions I test if document can be opened at all and catch the error - that's how higher versions are excluded. Lower versions are checked when allowedVersions is compared to docVersion:

 

/**
here I have paths generated from Powershell (I need to use it to get all indd files recursively from all folders and all possible nested subfolders)
*/
var pathsArray = [...]

for (var i = 0; i < pathsArray.length; i++) {
 // prevent open error to crush the script
 try {
  app.open(File(pathsArray[i]));
 } catch (err) {
  // save err info to log
  log(err)
 }
 // ... proceed with the script 
 var myDoc = app.activeDocument;
 var docVersion = myDoc.metadataPreferences.creator;

 // now I need to perform some actions depending on what is a doc version 
 var allowedVersion = 'Adobe InDesign CC 14.0 (Windows)';
 
 // ... proceed some actions
 if (docVersion == allowedVersion) {
 // ... some actions
 } else {
 // ... some action on lower versions
 }
}

 

So, at the end I don't need to have all possible values for .creator... 🙂 

Thanks for tips!

Votes

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 Expert ,
Oct 30, 2020 Oct 30, 2020

Copy link to clipboard

Copied

Hi,

 

Just to throw another answer out there, this one does not require the document to be opened in InDesign.

 

 

function getCreatorFromMetadata ( pathToFile) {
if ( ExternalObject.AdobeXMPScript == undefined){
	ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
}

var xmpFile = new XMPFile ( pathToFile, XMPConst.FILE_INDESIGN, XMPConst.OPEN_FOR_READ);
var xmpString = xmpFile.getXMP();
xmpFile.closeFile();
var versionString = xmpString.getProperty(XMPConst.NS_XMP, "CreatorTool");
return versionString;
}

 

 

This uses the metadata which should be there for a lot of versions of InDesign and gives you the creator of the document. It doesn't do any logic just shows a dialog with the string but should be good for a basis of a script.

 

(just thought it might be helpful)

 

Regards

 

Malcolm

Votes

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 ,
Oct 31, 2020 Oct 31, 2020

Copy link to clipboard

Copied

LATEST

Hi Malcolm,

Thanks, this looks like an alternative solution. Gotta remember it!

Cheers

Votes

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