- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
List of folders
Hi,
I am looking forward a solution to get a list of folder in a given directory using JSL.
Thanks in advance!
Jerome
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: List of folders
Created:
Sep 7, 2015 10:16 AM
| Last Modified: Jun 26, 2018 1:44 PM
(9568 views)
| Posted in reply to message from j_bonnouvrier 09-07-2015
Something like this, perhaps?
Names Default To Here( 1 );
// Given a path to a folder, returns a list of all folders therein (not recursive!)
dirList =
Function({path}, {Default Local},
// Get all files and folders in the specified folder
fid = Files In Directory( path);
// Remove all the files, just leaving the folders
for(f=NItems(fid), f>=1, f--, if(IsFile(path||"/"||fid[f]), RemoveFrom(fid, f)));
fid;
);
// Try out the function
path = "$DESKTOP";
Print(dirList(path));
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: List of folders
Created:
Sep 7, 2015 10:16 AM
| Last Modified: Jun 26, 2018 1:44 PM
(9569 views)
| Posted in reply to message from j_bonnouvrier 09-07-2015
Something like this, perhaps?
Names Default To Here( 1 );
// Given a path to a folder, returns a list of all folders therein (not recursive!)
dirList =
Function({path}, {Default Local},
// Get all files and folders in the specified folder
fid = Files In Directory( path);
// Remove all the files, just leaving the folders
for(f=NItems(fid), f>=1, f--, if(IsFile(path||"/"||fid[f]), RemoveFrom(fid, f)));
fid;
);
// Try out the function
path = "$DESKTOP";
Print(dirList(path));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: List of folders
Indeed, something like this should help!
I will try to insert this in my script, but it should help me to go forward!
Thanks a lot Ian!
Jérôme
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: List of folders
Created:
Jun 26, 2018 04:42 PM
| Last Modified: Jun 26, 2018 1:47 PM
(8127 views)
| Posted in reply to message from ian_jmp 09-07-2015
It works really well.