Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


action wizard filenames to array

New Here ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

I'm trying to store the filepath and filename of several PDFS in an array.  I'm using the action wizard and executing the code below.

if ( typeof global.zArray == "undefined" ) {

global.indexCnt = 0;

global.zArray = new Array();

}

var path2file = this.path;

var re = /.*\/|\.pdf$/ig;

var filename = path2file.replace(re,"");

var filepath = path2file;

global.zArray[global.indexCnt] = [filepath,filename];

global.indexCnt++;

I tried viewing all the elements in the array after all the files processed using the code below, but it only prints the last filepath and filename in the folder.

for (i=0;i<global.zArray.length;i++)
{
console.println(global.zArray);
}

What am I doing wrong??

TOPICS
Acrobat SDK and JavaScript, Windows

Views

124

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

correct answers 1 Correct answer

Adobe Community Professional , Aug 16, 2019 Aug 16, 2019
I tried your exact code and it worked just fine...

Likes

Translate

Translate
Adobe Community Professional ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

I tried your exact code and it worked just fine...

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
Adobe Community Professional ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

LATEST

PS. The indexCnt variable is not needed. You can simply add new items to your array using the push method.

I also don't understand the need to save the file path and file name as separate items, since the former includes the latter in it.

Instead of an array of arrays of two strings you can simply have an array of the full file-paths, and process it later on to get just the file name, if you need it in your code.

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