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

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

443

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 Expert , Aug 16, 2019 Aug 16, 2019

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

Votes

Translate

Translate
Community Expert ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

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

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 ,
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.

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