View previous topic :: View next topic |
Author |
Message |
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sat Sep 24, 2022 3:11 pm Post subject: Finding the number of files/folders in a folder |
|
|
Is there a way to find the actual number of files/folders that exist in a folder?
I'm using files@ with a wildcard of *.* to process file options. It would be helpful is there was a way to determine the number of files/folders that the wildcard would return so the ALLOCATE's I'm doing would get the full measure!
A single function would be very easy to implement. Failing that, a function similar to get_multiple_filenames@() would be useful in achieving the ultimate goal. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sat Sep 24, 2022 4:13 pm Post subject: |
|
|
Bill,
It's probably worth looking at the routine FILES@ (see the FTN77 Library Reference file in Silverfrost > Silverfrost Fortran FTN95: Documentation). Hint: it's on page 33 of the documentation.
Eddie |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sat Sep 24, 2022 5:30 pm Post subject: |
|
|
Eddie, that's the function I'm using. The note is that you give it the maximum number to be stored (as KIND=2), then it tells you how many you got. What I'm looking for is knowing how many to ask for, then allocating the data, then using FILES@() to get those files.
In some of the user's folders, I've seen as many as 15000 files.
They may have more.
I could allocate for the maximum size (32767), and may do that if an alternative is not available. This KIND=2 limit is a hold-back to an earlier day of FAT16 (512 files in a folder max) that with today's OS can be exceeded. Even with FAT32, the limit is 65534!
Granted, pathological, but some users don't like to use folders and separate their data.
Thanks for your comment, though. It got me to look deeper into the function and limits, and I learned something today!! |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sat Sep 24, 2022 6:27 pm Post subject: |
|
|
Bill,
You could always go through the alphabet, asking for how many files start with A, B, C etc and add the results.
NTFS has a very big limit on the number of files.
Eddie |
|
Back to top |
|
|
Robert
Joined: 29 Nov 2006 Posts: 445 Location: Manchester
|
Posted: Sat Sep 24, 2022 6:31 pm Post subject: |
|
|
Try pointing at C:\Windows\WinSxS |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sat Sep 24, 2022 8:12 pm Post subject: |
|
|
Robert, yeah, only 14000 files on my system. A good test set, though! |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7930 Location: Salford, UK
|
Posted: Sun Sep 25, 2022 8:11 am Post subject: |
|
|
There is an undocumented function for this.
Code: | program main
use clrwin
integer n
n = count_files@("C:\techsupport")
print*, n
end program |
I will add this to the documentation. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2555 Location: Sydney
|
Posted: Tue Sep 27, 2022 7:37 am Post subject: |
|
|
I use FILES@ and FILES8@ for scanning tree directories.
I use an array to store all the information, appending to the work array.
The array can be larger than 32767, but only the next 32767 can be provided to FILES@ for each directory.
I have been using FILES8@ for years to scan a disk for recent files etc ( my NSIZE utility), especially for the files changed in the last week when doing timesheets !
I would be happy to provide a link to my latest win-32 version. ( I don't think I have converted this to /64, as there are a few integer*2 constraints.
C:\Windows\WinSxS is interesting !
https://www.dropbox.com/s/pa16n669iet7fdk/nsize_13.zip?dl=0
try
"nsize /?" for some help, or
"nsize /-d" to dump out all files in the current tree, or
"nsize c:\ /si 010922 /-d" for all files on teh c: drive that have changed since 1-Sep-22
This is my go to utility to find lost files or projects. |
|
Back to top |
|
|
|