forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Finding the number of files/folders in a folder

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sat Sep 24, 2022 3:11 pm    Post subject: Finding the number of files/folders in a folder Reply with quote

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
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Sep 24, 2022 4:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sat Sep 24, 2022 5:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Sep 24, 2022 6:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Robert



Joined: 29 Nov 2006
Posts: 444
Location: Manchester

PostPosted: Sat Sep 24, 2022 6:31 pm    Post subject: Reply with quote

Try pointing at C:\Windows\WinSxS
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sat Sep 24, 2022 8:12 pm    Post subject: Reply with quote

Robert, yeah, only 14000 files on my system. A good test set, though!
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun Sep 25, 2022 8:11 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Sep 27, 2022 7:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group