How to list the files in a directory in p5?

I want to write a sketch to open a random image from a folder.

I was able to do this in Processing by doing something like this:

String path="/somePath";
File dir = new File(path);
String[] list = dir.list();
int randomImage=random(0,list.length);
PImage pic;
pics=loadImage(path+list[randomImage]);

Do you have any ideas on how to do this in P5? Also, I don't seem to be able to use an absolute path, any thoughts?

Thank you!

Sign In or Register to comment.