Copy link to clipboard
Copied
Hey, I am trying to get the names of images in a Folder. Tried using a script like this but got an error saying folder.getFiles is not a function. How can I do this ?
"""
Hi @Victor29751988fsbx , You defined the myFolder variable, but then referenced an undefined variable folder. Try this:
var fldr = Folder.selectDialog("Select the folder containing the images", "");
var na = []
if(fldr != null){
var fa = fldr.getFiles(/\.(jpg|jpeg|png|gif)$/i);
for (var i = 0; i < fa.length; i++){
na.push(fa[i].name)
};
}
$.writeln(na)
//returns an array of file names
Copy link to clipboard
Copied
Hi @Victor29751988fsbx , You defined the myFolder variable, but then referenced an undefined variable folder. Try this:
var fldr = Folder.selectDialog("Select the folder containing the images", "");
var na = []
if(fldr != null){
var fa = fldr.getFiles(/\.(jpg|jpeg|png|gif)$/i);
for (var i = 0; i < fa.length; i++){
na.push(fa[i].name)
};
}
$.writeln(na)
//returns an array of file names
Find more inspiration, events, and resources on the new Adobe Community
Explore Now