# Import a lot of svg

**URL:** <https://discourse.processing.org/t/import-a-lot-of-svg/24805>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [October 21, 2020, 5:03pm UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805 "2020-10-21T17:03:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimdimtri](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@Dimdimtri](https://discourse.processing.org/u/Dimdimtri)\
**Post date:** [October 21, 2020, 5:03pm UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805/1 "2020-10-21T17:03:42Z")

</div>

Hi everyone, I wanted to know if there is a solution to import a lot of svg at the same time. they are all in the same folder. I have like 100 and I can’t see myself writing “PShape bot, bot2, bot3 …;”

Because I wanted to overlap each svg.

Thank you in advance for your answer.

PShape bot, bot2, bot3 ;

void setup() {  
fullScreen();  
// The file “bot1.svg” must be in the data folder  
// of the current sketch to load successfully  
bot = loadShape(“frame-0052 17.55.11 17.56.26.svg”);  
bot2 = loadShape(“frame-0053 17.55.11 17.56.26.svg”);  
bot3 = loadShape(“frame-0056 17.55.11 17.56.26.svg”);  
noLoop();

}

void draw(){

background(0);  
stroke(255);  
noFill();

bot.disableStyle(); // Ignore the colors in the SVG  
shape(bot);

bot2.disableStyle(); // Ignore the colors in the SVG  
shape(bot2);// Draw

bot3.disableStyle(); // Ignore the colors in the SVG  
shape(bot3);// Draw  
}

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [October 21, 2020, 10:41pm UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805/2 "2020-10-21T22:41:25Z")

</div>

Hello and welcome to the forum!

It’s great to have you here!

you can get a list of all files in the folder easily: [A music player that automatically adds .wav or .mp3 files in the data folder to list?](https://discourse.processing.org/t/a-music-player-that-automatically-adds-wav-or-mp3-files-in-the-data-folder-to-list/22473/2)

Chrisir

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [October 22, 2020, 7:46am UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805/3 "2020-10-22T07:46:33Z")

</div>

Hi @Dimdimtri

Welcome to the forum! 🙂

I believe that you can also look for an ArrayList to load the files and add the shapes. However, this will only work if the filenames are equal or at least follow the same format. In your example, they all have the following format:  
“frame-00XX 17.56.26.svg”  
So, a loop might be a good idea. Something like:

```auto
int listSize = 100; //number of files
int count = 0; //lets asssume that the first svg has the name frame-0000 17.56.26.svg
//If it does not have just change to whatever integer you want it to start

ArrayList<PShape> bots; //ArrayList of shapes

void setup() {
  bots = new ArrayList<PShape>(); 
 //Load all the .svg files
  for (int i = count; i < count + listSize; i++) {
    //println("frame-00" + i + " 17.56.26.svg"); //DEBUG THE FILENAME
    String filename = "frame-00" + i + " 17.56.26.svg";
    bots.add(loadShape(filename)); //Load shape and add
  }
}

void draw() {
  background(0);
  stroke(255);
  noFill();
  
  //For enhanced loop to disable and display shapes
  for(PShape bot : bots){
    bot.disableStyle();
    shape(bot);
  }
}

```

Find above some useful resources as well

> **Resources**
>
> ArrayList: [ArrayList / Reference / Processing.org](https://processing.org/reference/ArrayList.html)  
> The Coding train ArrayList: [https://www.youtube.com/watch?v=HnSJZ4qTcwY&ab\_channel=TheCodingTrain](https://www.youtube.com/watch?v=HnSJZ4qTcwY&ab_channel=TheCodingTrain)  
> For enhanced loop: [Java For-each Loop | Enhanced For Loop - javatpoint](https://www.javatpoint.com/for-each-loop)

Best regards

---

<div class="post-metadata">

**Author:** ![Dimdimtri](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@Dimdimtri](https://discourse.processing.org/u/Dimdimtri)\
**Post date:** [October 22, 2020, 9:05am UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805/4 "2020-10-22T09:05:05Z")

</div>

Grazie Mille !!!

Thanks, it works perfectly! I modified the code a bit, and I also changed my file saving mode to make things easier. Thanks again . It’s been a week since I discovered Processing3 and I find it really interesting 🙂

thanks guys

---

<div class="post-metadata">

**Author:** ![MiguelSanches](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/miguelsanches/32/11172_2.png) [@MiguelSanches](https://discourse.processing.org/u/MiguelSanches)\
**Post date:** [October 22, 2020, 9:08am UTC](https://discourse.processing.org/t/import-a-lot-of-svg/24805/5 "2020-10-22T09:08:42Z")

</div>

Glad it worked and could help! 🙂

Allows try to look for resources either on Processing documentation or java. It is your best tool to solve your problems.
