Copy link to clipboard
Copied
Hi,
I need to report if the link folder contains any subfolder or not. The below coding is working fine but in some files it shows some folder names but when i see the parent link folder then it is not visible. How to ignore the hidden folders. Is it the method i used is correct? Because some times it show the result wrongly.
var inputFolder = Folder(app.activeDocument.allGraphics[0].itemLink.filePath).parent;
var fileList = inputFolder.getFiles();
var myArray=[]
flag=0;
for(i=0;i<fileList.length;i++){
var myfile=fileList;
if(myfile.name==".DS_Store") continue;
if((myfile instanceof Folder) && (!myfile.hidden)){
myArray.push(myfile);
if(myArray.length>0){flag=1;}
}
}
if(flag==1){alert("ERROR: Some SubFolder(s) present in the Link Folder. "+ "Name and Path of SubFolder(s)\n"+decodeURI(myArray.join("\n")))}
if(flag==0){alert("No SubFolder(s) present in the Link Folder")}
Also is it any other method we can use to achieve my need?
Thanks,
K
Copy link to clipboard
Copied
Hm.
Maybe it would help to check the name with a RegExp like that:
/^\./
Don't know if that is sufficient.
At least all files and folders on OSX with a name beginning with a dot are invisible.
Regards,
Uwe
Copy link to clipboard
Copied
Thanks Uwe, i will try and let you know.
Copy link to clipboard
Copied
Hi Kartik,
it's not perfect at all.
This is only finding files and folders with a dot in the beginning of a name.
But there are also folders around—e.g. in the root folder of a system harddisk—where other folders without the dot in the file name are not visible to the user. Maybe you look better after an AppleScript based solution.
Regards,
Uwe
Copy link to clipboard
Copied
Hi Laubender,
Yes i also had a thought about getting solution from Applescript. Because it gives better results in order searching for Mac related things.
But unfortunately i dont have knowledge in Applescript.
Thanks,
K