Recently Browsing 0 members
No registered users viewing this page.
I'm trying to make a listing of all files in subdirectories on a specific level in a folder structure. Let me explain, visually, this will help things a lot.
I have a folder structure like this:
ROOT |--- SUBDIR 1 | |---- SUBDIR 1.1 | |----- SUBDIR 1.1.1 | |---- File1.ext | |----- SUBDIR 1.1.2 | |---- File2.ext | |----- SUBDIR 1.1.3 | |---- File2.ext | |----- SUBDIR 1.1.4 | |---- File2.ext | |----- SUBDIR 1.1.5 | |---- File2.ext | |---- SUBDIR 1.2 | |----- SUBDIR 1.2.1 | ..... | |---- SUBDIR 1.3 .... I use _FileListToArrayRec twice:
- once to make an array of the specific directories I should be working at: I need all files on the x.x level, so it will go just until that depth using a negative integer for $iRecur
- once again to create an array of all files found under that directory and its subdirectories (level x.x.x\files...)
What happens now is that _FileListToArrayRec will always include all levels before the maximum depth is reached. The result would look like this
Row 0 15 Row 1 Root\Subdir 1 Row 2 Root\Subdir 2 Row 3 Root\Subdir 3 Row 4 Root\Subdir 1\Subdir 1.1 Row 5 Root\Subdir 1\Subdir 1.2 Row 6 Root\Subdir 1\Subdir 1.3 ... Needless to say that when my second function iterates over this array, it will find all files twice. Once on the x level, once again on the x.x level. There is no way for me not to use the recursive option in the second iteration, since the files are actually in a subdirectory there.
Where are the wizards of programming logic here? Since I can't seem to find a comprehensible or easily implementable solution for this issue.
Thanks in advance and kind regards,
In a folder with some files that have no extension (for example the hosts file in C:\Windows\System32\driversetc), FileListToArrayRec does not return the same thing than _FileListToArray if I use *.* as filter :
_FileListToArray("C:\Windows\System32\driversetc", "*") : returns all files
_FileListToArray("C:\Windows\System32\driversetc", "*.*") : returns all files
_FileListToArrayRec("C:\Windows\System32\driversetc", "*") : returns all files
_FileListToArrayRec("C:\Windows\System32\driversetc", "*.*") : returns only files with extensions
It seems logic that FileListToArrayRec and FileListToArray should have the same behaviour with the same filter, no ?
It's not important at all for me, but maybe developers will want to ensure that these two functions react in the same way...
Edit : sorry if this post is not in the good section. Please move it if needed.