Copy link to clipboard
Copied
Hi everyone!
I would like to check if a folder exist. I was trying with this code but doesn't work.
I will thank you in advanced if you know a better way to do this.
Best regards_
- Code not working
path = Folder.desktop + "/MyFiles";
var folder = new Folder(path);
if(!folder.exists){
alert("Folder doesn't exists");
}else{
alert("Folder Exist");
}
Copy link to clipboard
Copied
Your code working!
For example:
alert( 'isFolder: ' + Folder('~/Desktop').exists );
Copy link to clipboard
Copied
Hi Puthoskey,
there are some mistakes in your code. Please try something like this:
//path = Folder.desktop + "/MyFiles"; //--------------// declare (var) your variable --> but "path" is IMHO not the best choice for the name of a variable
//var folder = new Folder(path); // ?????? what do you want with this ????
var yourFolder = new Folder("~/Desktop/MyFiles"); // I like this syntax more than --> Folder.desktop
if(yourFolder.exists) {
alert("Folder exists");
}else{
alert("Folder doesn't exists");
}
Have fun
![]()
<edited by pixxxel schubser>
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more