• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get rid of hidden folders

Guide ,
Mar 02, 2017 Mar 02, 2017

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

TOPICS
Scripting

Views

234

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2017 Mar 03, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 03, 2017 Mar 03, 2017

Copy link to clipboard

Copied

Thanks Uwe, i will try and let you know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2017 Mar 03, 2017

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 03, 2017 Mar 03, 2017

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines