Applying procedure to every file on a drive

Applying procedure to every file on a drive


For EVERY filename present on a hard drive, I need to convert the path and filename to a string and then evaluate the string for certain conditions. If those conditions are True, modify the string and append the string to “DataBase.txt. Otherwise, skip the file and move on to the next file, etc.

My program will successfully do this with one file at a time, but I don’t want to have to manually go through every file on the hard drive.How do I tell the program how to get every file on the drive? (Do first dir in C: then do and subdirs in that nauseum…then do second dir in C; and so on.)



While a small ISAPI component would run faster, you can get away with a littlerecursive VBScript and the FileSystemObject. If you have a large number of files on thedrive, you may need to extend the script’s timeout. Here’s some code for doing that:

Set fs = CreateObject("Scripting.FileSystemObject")
Call ShowFolderList("c:")
Set fs=Nothing

Sub ShowFolderList(folderspec)
On error resume next
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
   ' Do any processing of the filename and path here
   ' For demonstration, this displays the filename and path
   ' If you want just the filename use f1.Name
Response.Write f1.Path & "
Set fc2 = f.SubFolders
For Each f1 in fc2
End Sub

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular