Loading multiple files/jobs into a single CLI argument

Post Reply
kylek23
Newbie
Posts: 3
Joined: Fri Sep 14, 2012 11:17 pm

Loading multiple files/jobs into a single CLI argument

Post by kylek23 »

I need to combine multiple HTML files into a single PDF using Prince XML CLI. Below is the manual CLI I use:





/usr/local/bin/prince /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01_at_their_service_outside_counsels_role_in_working_with_large_corporate_clients.html /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01_how_can_you_help_promote_national_disability_awareness.html /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01_is_the_electoral_college_a_party_school.html /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01_the_superiority_requirement_of_rule_23_packs_a_big_punch.html /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01_your_duty_to_report_thirdparty_illegal_conduct.html -o /Users/kolbek/Desktop/princeprocessmulti/ABA_TYL_v017n01.pdf



Can calling all the file paths be accomplished through variables or do I need a script?
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Loading multiple files/jobs into a single CLI argument

Post by dkelly »

Are the files in a Switch job folder? If so, you can use this script to set the value of the "Execute command" arg property.



var argStr = "";

var theJobFolder = job.getPath();

if (job.isFolder()) {

var theJobDir = new Dir( theJobFolder );

var theFilesList = theJobDir.entryList( "*", Dir.Files );

for( var index = 0; index < theFilesList.length; index++ ) {

var theFilePath = theJobFolder + "/" + theFilesList[ index ];

argStr.append(""" + theFilePath) + "" ";

}

} else {

argStr = "%1";

}

argStr;



Learn advanced Javascript for Switch

Full day seminar during Graph Expo in Chicago, Oct 8th, 2012

http://www.brownpapertickets.com/event/264833



Dwight Kelly

Apago, Inc.
kylek23
Newbie
Posts: 3
Joined: Fri Sep 14, 2012 11:17 pm

Loading multiple files/jobs into a single CLI argument

Post by kylek23 »

Thanks for the quick reply, Dwight.



I've tried the script in the execute command and as a script element, but I get the following error:



Error in line 12 of script : TypeError. Undefined member function 'append' for object '' of type: 'String'



If it is a script element, will the execute command pickup the normal %1 as the string from the script?



Do I need to worry about the last bit of the argument: "-o "%2""?
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Loading multiple files/jobs into a single CLI argument

Post by dkelly »

var argStr = "";

var theJobFolder = job.getPath();

if (job.isFolder()) {

var theJobDir = new Dir( theJobFolder );

var theFilesList = theJobDir.entryList( "*", Dir.Files );

for( var index = 0; index < theFilesList.length; index++ ) {

var theFilePath = theJobFolder + "/" + theFilesList[ index ];

argStr += (""" + theFilePath) + "" ";

}

} else {

argStr = "%1";

}

argStr += " -o %2";

argStr;
kylek23
Newbie
Posts: 3
Joined: Fri Sep 14, 2012 11:17 pm

Loading multiple files/jobs into a single CLI argument

Post by kylek23 »

I got it to work. It was just missing some escaped quotes and a semicolon. This is great because I can use it for both single and combined jobs.



var argStr = "";

var theJobFolder = job.getPath();

if (job.isFolder()) {

var theJobDir = new Dir( theJobFolder );

var theFilesList = theJobDir.entryList( "*", Dir.Files );

for( var index = 0; index
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Loading multiple files/jobs into a single CLI argument

Post by dkelly »

You shouldn't have to quote the substitution variables %1 and %2
Post Reply