Highlighted

script to add parent directory to source field

New Here ,
Aug 15, 2020

Copy link to clipboard

Copied

hello, i have a script i'm working on and i'm stuck here. 

 

i have a var that captures the source folder i'm working out of here, and the username of the computer working

 

var sourceFolderName = doc.path.name;

var userName = $.getenv('USER');

 

in part of the script i put the username into a metadata field here, and place the source folder into the keywords section of metada, but i'd rather it be in the "Source" field. 

 

doc.info.credit = userName;
var keywords = doc.info.keywords;
keywords.push(sourceFolderName);
doc.info.keywords = keywords;

 

i started to name the new rows to this

 

var source = doc.info.source;
source.push(sourceFolderName);
doc.info.source = source;

 

but that results in an error "ReferenceError: source.push is not a function: on line 88"

TOPICS
Actions and scripting

Views

40

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

script to add parent directory to source field

New Here ,
Aug 15, 2020

Copy link to clipboard

Copied

hello, i have a script i'm working on and i'm stuck here. 

 

i have a var that captures the source folder i'm working out of here, and the username of the computer working

 

var sourceFolderName = doc.path.name;

var userName = $.getenv('USER');

 

in part of the script i put the username into a metadata field here, and place the source folder into the keywords section of metada, but i'd rather it be in the "Source" field. 

 

doc.info.credit = userName;
var keywords = doc.info.keywords;
keywords.push(sourceFolderName);
doc.info.keywords = keywords;

 

i started to name the new rows to this

 

var source = doc.info.source;
source.push(sourceFolderName);
doc.info.source = source;

 

but that results in an error "ReferenceError: source.push is not a function: on line 88"

TOPICS
Actions and scripting

Views

41

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
Aug 15, 2020 0
r-bin LATEST
Adobe Community Professional ,
Aug 15, 2020

Copy link to clipboard

Copied

info.source is a string, not an array (see scripting docs).
Therefore, the push function is not applicable.
 
Instead of this
 
var source = doc.info.source;
source.push(sourceFolderName);
doc.info.source = source;

use
 
doc.info.source = sourceFolderName;

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
Reply
Loading...
Aug 15, 2020 0