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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Going through directories and reading filenames - help!

Status
Not open for further replies.

Sech

Programmer
Jul 5, 2002
137
GB
Hi all,

I am currently creating a database which stores reports away in a directory structure. This structure is made up of various subdirectories

e.g. Database Dir\Report No\Status\Sent
In the above example the reports when first exported are stored as Excel files in Database Dir\Report No\Status\. When they are automatically sent to the customers they are moved to the Sent subdirectory.

I am creating a process that has to remove all files older than 6 months. The way I find out the date of the file is that it makes up part of the filename. Does anyone know how to go through each of the subdirectories under the Database Dir and bring back each filename under them in turn? I would like to do this without having to calculate each subdirectory name if possible. In other words it should scan through them all going up and down in levels where required

Example of process:

Under the Database Dir there is two stored reports. The first is in Database Dir\UserReport\Open\Sent\. The second is in Database Dir\GroupReport\Closed\. So first it checks in Database Dir and finds UserReport subdir and GroupReport subdir. So it goes into UserReport subdir and in here it finds Open. So it goes into Open subdir and in here it finds Sent. So it goes into Sent subdir and in here it finds the file. It reads the filename and gets the date. There are no more files so it goes back to Open subdir. There are no more files or subdirs here so it goes back to UserReport. There are no more files or subdirs here so it goes back to Database Dir...etc

Also does anyone know how to read a file and bring back the created date from it?
 
The Microsoft Scripting Runtime Library will do the trick (scrrun.dll), which is included when you install MS Office 2000 (and above).

Have a look at this MS webpage (MSDN) for an example on how to use it:

The library contains files, folders (can enumerate though subfolders) so it should do what you need.

Cheers,
Dan
 
Opps, My last line was meant to say:

"The library contains files and folders objects (can also enumerate though subfolders) so it should do what you need."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top