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

trying to place images in frames fails to iterate

Engaged ,
Dec 26, 2020 Dec 26, 2020

Copy link to clipboard

Copied

I have a single frame per page and I'm trying to place a folder of images 1 per page. When I run this code I get the first image on every page. Why is that?

 

 

var myFunction = function(){
       var sourceFolder = Folder.selectDialog("Select the source folder");
       var myFiles = sourceFolder.getFiles();
  
       for (i = 0; i < myFiles.length; i++){
            for (j=0; i < myDoc.pages.length; j++){
                myDoc.pages[j].rectangles[0].place(myFiles[i]);
                }     
        }
}

myFunction();

 

 

TOPICS
Scripting

Views

173

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

Enthusiast , Dec 26, 2020 Dec 26, 2020

You are looping through the pages per file. So
image 1: page 1, page 2, page 3...


In your snippet you don't need to loop through the pages.

for (i = 0; i < myFiles.length; i++){                 
   myDoc.pages[i].rectangles[0].place(myFiles[i]);
}

 
btw. I would check if there are enough pages and add if necessary/you have more files than pages.

Votes

Translate

Translate
Enthusiast ,
Dec 26, 2020 Dec 26, 2020

Copy link to clipboard

Copied

LATEST

You are looping through the pages per file. So
image 1: page 1, page 2, page 3...


In your snippet you don't need to loop through the pages.

for (i = 0; i < myFiles.length; i++){                 
   myDoc.pages[i].rectangles[0].place(myFiles[i]);
}

 
btw. I would check if there are enough pages and add if necessary/you have more files than pages.

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