Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to enumerate all files and sizes in a directory?

Status
Not open for further replies.

dBjason

Programmer
Mar 25, 2005
355
US
Hello,

It's been awhile, and I'm rusty. Here's what I need to do (Microsoft XP running MS Office 2003):

Somehow I need to enumerate any and all files (including subdirectories) into a table. I have a table with the following fields:

FileNameAndDirectory
FileSize

Both are set to maximum Text(255).

What I need to do (somehow) is to utilize the FileSystemObject to enumerate any and all files in a directory, to include subdirectories. So my table would be populated like this:

H:\File1.exe 131kb
H:\Directory1\File2.exe 145kb
H:\Directory1\Directory2\File1.exe 131kb
H:\Directory1\Directory2\Directory3\File3.jpg 500kb
H:\Directory1\Directory2\Directory3\File4.jpb 650kb

The goal of all this, after I can enumerate every file in a specified path (in this case, a drive letter) is to identify duplicate filenames and sizes in a given directory and all of it's subdierctories (there are hundreds of subdirectories in this case). I can easily parse out the file names and query the table afterwards, but have no idea how to 1) list every file in every subdirectory in a given path to populate my table and 2) obtain each file's size.

The user has several thousand images and files which are duplicates in subdirectories (he backed everything up the easy way -- copy a folder with it's subfolders and paste to a drive). In this case, he would need to know that File1.exe is duplicated in directories "H:\" and "H:\Directory1\Directory2\".

I really just need a way to populate a field in a table with every filename and directory on a given drive.

My memory of the FileSystemObject is eluding me, can anyone give me any references?

Thanks for any and all help!!!

Best Regards,
Jason
 

Thank you both Ed and Geoff, I will check out both options!

Thanks again,
Jason
 
Sadly after researching, I can't use either. MSDN only wants to give info for C/C++ and SQL Server Enums, not VBA and drive files through the FileSystemObject. Sadly, I don't have the time to parse out a CSV file or run another prog from a VBA module to a command line (even worse, I'm in China on a Chinese computer -- which adds even more complications to the issue).

Anyone have any other resources? I just need to enumerate user files and subdirectories from a given drive path. Sorry to be so picky, but circumstances are beyond my control!

Thanks for your help,
Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top