Import a lot of svg

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() {
// 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”);


void draw(){


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

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

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

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?


1 Like

Hi @Dimdimtri

Welcome to the forum! :slight_smile:

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:

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() {
  //For enhanced loop to disable and display shapes
  for(PShape bot : bots){

Find above some useful resources as well


The Coding train ArrayList:
For enhanced loop:

Best regards

1 Like

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 :slight_smile:

thanks guys


Glad it worked and could help! :slight_smile:

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