i need to loop only all dir in C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\
i can have this subdir:
1
2
3
...
20
now for each dir i need to list only a image file and retrieve the name of image file
note:
immagine.jpg is the possible list of dir
immagine1.jpg is the possible list of file of dir 1
LOOP DIR and retrieve name of image
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
LOOP DIR and retrieve name of image
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: LOOP DIR and retrieve name of image
I see that C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\1 has further subdirectories (AL, AT, ...)
Do you need to list the file names in those subdirectories too?
Do you need to list the file names in those subdirectories too?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: LOOP DIR and retrieve name of image
Code: Select all
Sub Test()
Dim fso As Object
Dim fld As Object
Dim sfl As Object
Dim fil As Object
Set fso = CreateObject(Class:="Scripting.FileSystemObject")
Set fld = fso.GetFolder("C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI")
For Each sfl In fld.SubFolders
For Each fil In sfl.Files
Debug.Print fil.Path ' or fil.Name
Next fil
Next sfl
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 585
- Joined: 14 Nov 2012, 16:06
Re: LOOP DIR and retrieve name of image
Code: Select all
Sub M_snb()
msgbox createobject("wscript.shell").exec("cmd /c dir C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI\*.jpg /b/s").stdout.readall
Emd Sub
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: LOOP DIR and retrieve name of image
GREAT!HansV wrote: ↑22 Aug 2023, 11:54Code: Select all
Sub Test() Dim fso As Object Dim fld As Object Dim sfl As Object Dim fil As Object Set fso = CreateObject(Class:="Scripting.FileSystemObject") Set fld = fso.GetFolder("C:\Lavori_Vb6\LEGGI_CSV_COMUNI\STEMMI") For Each sfl In fld.SubFolders For Each fil In sfl.Files Debug.Print fil.Path ' or fil.Name Next fil Next sfl End Sub
tks bro