Skip to main content
bflieck
Participating Frequently
August 15, 2020
Question

script to add parent directory to source field

  • August 15, 2020
  • 1 reply
  • 243 views

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"

This topic has been closed for replies.

1 reply

Legend
August 15, 2020
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;