Page 2 of 2
Re: ListFiles - scan for files easily
Posted: Thu Aug 04, 2011 2:56 am
by kenmo
Just a heads-up, I replaced the code in the original post with an updated version.
Changes:
Two new flags: NoHidden (excludes hidden files from results) and HiddenOnly (self explanatory)
Slightly changed the behavior of the AllowNoExt flag. Now, setting that flag and not specifying any other file types allows you to scan ONLY for files without extensions (previously you would have to set the flag and specify at least one extension, like *.faketype ).
Re: ListFiles - scan for files easily
Posted: Sun Dec 04, 2011 2:16 pm
by kinglestat
Thanks for this
Very nicely presented
Was going to code something simple and found this nice solution
Beer's on me if you are ever around!
Re: ListFiles - scan for files easily
Posted: Thu May 17, 2018 7:14 am
by forumuser
@kenmo
Would it be possible to add a limitation on how deep the recursion goes?
Code: Select all
E.g.:
0 = No recursion limit
1, 2, 3, ... = Only traverse <x> subfolders deep
For example a directory structure:
R:\VPN
R:\VPN\data
R:\VPN\logs
R:\VPN\logs\provider
R:\VPN\logs\provider\1
R:\VPN\logs\provider\2
Then 1 would only recurse into these folders:
R:\VPN
R:\VPN\data
R:\VPN\logs
And 2 only into these:
R:\VPN
R:\VPN\data
R:\VPN\logs
R:\VPN\logs\provider
Etc.
Another question:
Would it be possible to present found files + folders ([x] Include folders is used)
in a way that files for a folder are always displayed first? Atm it is a purely alphabetical listing
E.g. this is the current result:
Code: Select all
R:\VPN\
R:\VPN\config.ini
R:\VPN\data\
R:\VPN\OpenVPN.exe
...
and it would be extremely nice if there was an option to display it like this:
Code: Select all
R:\VPN\
R:\VPN\config.ini
R:\VPN\OpenVPN.exe
R:\VPN\data\
...
Which means:
Code: Select all
<folder>
<folder>\<files for that folder>
<folder>\<first sub folder>
<folder>\<first sub folder>\<files for that first subfolder>
<folder>\<second sub folder>
<folder>\<second sub folder>\<files for that second subfolder>
Re: ListFiles - scan for files easily
Posted: Thu May 17, 2018 8:50 am
by Michael Vogel
Quick and dirty to limit the search depth...
Code: Select all
; Scan sub-folder, add sub-count to current count
If (Recurse) And CountString(Relative,"\")<#maxdepth
Recurse = xListFiles(Root, Relative + Name, Results(), Extensions, Flags)
If (Recurse > 0) And depth<#maxdepth
Count + Recurse
EndIf
EndIf
Re: ListFiles - scan for files easily
Posted: Fri May 18, 2018 11:29 pm
by forumuser
Thanks a lot, Michael, that solves the recursive problem for me!
Re: ListFiles - scan for files easily
Posted: Fri May 18, 2018 11:36 pm
by kenmo
You can also try a newer IncludeFile I wrote called "ScanFolder"
https://raw.githubusercontent.com/kenmo ... Folder.pbi
Code: Select all
Procedure.i ScanFolder(Folder.s, Flags.i = #Null, Extensions.s = "", RecurseDepth.i = 0, RegexPattern.s = "")
Re: ListFiles - scan for files easily
Posted: Sat May 19, 2018 12:18 am
by davido
@kenmo,
Very useful. Thank you for sharing.

Re: ListFiles - scan for files easily
Posted: Sat May 19, 2018 1:24 pm
by forumuser
Thank you kenmo!