C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\
in this dir have other sub dir, similar
\1
\2
\3
...
xx
in internal of each subdir have a files, i need a list of files with this format:
1-files.txt
1-prova.gif
ecc...
LOOPING dir and retrieve files name....
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
LOOPING dir and retrieve files name....
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78530
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: LOOPING dir and retrieve files name....
Code: Select all
Sub LoopSubDir()
Const strPath = "C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\"
Dim fso As Object
Dim fld As Object
Dim sfl As Object
Dim fil As Object
Dim strOutput As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(strPath)
For Each sfl In fld.SubFolders
For Each fil In sfl.Files
strOutput = sfl.Name & "-" & fil.Name
Debug.Print strOutput
Next fil
Next sfl
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: LOOPING dir and retrieve files name....
Great bro!HansV wrote: ↑02 Aug 2023, 14:55Code: Select all
Sub LoopSubDir() Const strPath = "C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\" Dim fso As Object Dim fld As Object Dim sfl As Object Dim fil As Object Dim strOutput As String Set fso = CreateObject("Scripting.FileSystemObject") Set fld = fso.GetFolder(strPath) For Each sfl In fld.SubFolders For Each fil In sfl.Files strOutput = sfl.Name & "-" & fil.Name Debug.Print strOutput Next fil Next sfl End Sub