I'm trying the following .vbs script to copy the first file from every folder to a new location in windows, but I'm not sure how to copy files that are nested 2 or 3 sub-folders deep. Can anyone help with this?
Const rootFolder = "c:\Rootfolder"
Const targetFolder = "c:\TargetFolder"
Set fso = CreateObject("Scripting.FileSystemObject")
For Each objFolder In fso.GetFolder(rootFolder).SubFolders
i = 0
For Each sFile In objFolder.Files
If i = 0 then
fso.GetFile(sFile).Copy targetFolder & "\" & fso.GetFileName(sFile),True
i = 1
End if
Next
Next