Skip to main content
tpk1982
Legend
March 2, 2017
Question

How to get rid of hidden folders

  • March 2, 2017
  • 1 reply
  • 303 views

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

This topic has been closed for replies.

1 reply

Community Expert
March 3, 2017

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

tpk1982
tpk1982Author
Legend
March 3, 2017

Thanks Uwe, i will try and let you know.

Community Expert
March 3, 2017

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