SPINAL-FUSION
asked on
EXTRACT FILE NAMES FROM A DIRECTORY TO A USABLE TEXT BASED LIST
I tried to do a search and found nothing useful. Our customer sent us a DVD with 5 main directory folders. Each of these 5 folders contains hundreds of subfolders. And each subfolder contains from 1 to as many as 10 part drawing in a standard PDF format. What I'd like to do is extract all the file names in these folders and subfolders and create a list which I can eventually manipulate in Excel to determine if we have ever made this part before. I think I can manage the back half of this little project, if I could just get a little help with creating the text list.
My network is based on WinServer 2003 w/AD. Workstations use XP Pro. I have the most experience using Excel with macros to get where I'm going.
Thanks in advance,
Bryan
My network is based on WinServer 2003 w/AD. Workstations use XP Pro. I have the most experience using Excel with macros to get where I'm going.
Thanks in advance,
Bryan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also do this as an Excel VBA Makro:
Bye, Olaf.
Dim row As Integer
Sub Start()
GetDriveFiles "F:\"
End Sub
Sub GetDriveFiles(drive As String)
Set o = CreateObject("Scripting.FileSystemObject")
Set oFolder = o.GetFolder(drive)
row = 1
RecurseFolder oFolder
End Sub
Sub RecurseFolder(ByVal oFolder As Object)
For Each oFile In oFolder.Files
ActiveWorkbook.ActiveSheet.Cells(row, 1).Value = oFolder.Path + "\" + oFile.Name
row = row + 1
Next
For Each oSubfolder In oFolder.SubFolders
RecurseFolder oSubfolder
Next
End Sub
Bye, Olaf.
ASKER
Did exactly what I asked for. Sorry it took 3 days to test. I have been missing from the office due to health reasons. Thanks for the replies. And I may have posed in the wrong area as the VB base reply was more complicated than I needed.
Open in new window
ADIR function has additional parameters so you may decide what will be listed and what format of the filenames are on output.The text output can be processed in Excel. You may decide about the different output format. See COPY TO command in VFP help.
You may test the code on some subfolder of your harddrive first.