Script VBA para listar todos os arquivos de texto ....
'Wscript.Echo "begin."
Set objFSO = CreateObject("Scripting.FileSystemObject")
DIM folderStart,fileOutName, fileH
On Error Resume Next
folderStart = InputBox("Drive or folder to start looking in", , "D:\prog\github\academic")
fileOutName = InputBox("File to write results", "Output file", "c:\tmp\filesFounds.note")
Set objSuperFolder = objFSO.GetFolder(folderStart)
Set fileH = objFSO.OpenTextFile(fileOutName,2 ,1)
fileH.WriteLine ("Start " & Now)
Call ShowSubfolders (objSuperFolder, fileH)
Call fileH.WriteLine ("end " & Now)
fileH.Close
Wscript.Echo "Done " & Now
WScript.Quit 0
Sub ShowSubFolders(fFolder, fileH)
Err.clear
On Error Resume Next
Set objFolder = objFSO.GetFolder(fFolder.Path)
If Err.Number = 0 then
Set colFiles = objFolder.Files
If Err.Number = 0 then
For Each objFile in colFiles
If Err.Number = 0 then
If UCase(objFSO.GetExtensionName(objFile.name)) = "TXT" Then
If len(objFile.name) = 9 Then
'Wscript.Echo objFile.Name
fileH.WriteLine (objFile.path)
'fileH.WriteLine (objFile.name) 'only short name
End If
End If
End If
Next
End If
For Each Subfolder in fFolder.SubFolders
Call ShowSubFolders(Subfolder, fileH)
Next
End If
End Sub
Original
'Wscript.Echo "começa." Definir objFSO = CreateObject ("Scripting.FileSystemObject") Pasta DIMStart, fileOutName, fileH folderStart = InputBox ("Drive ou pasta para começar a procurar", "c: \") fileOutName = InputBox ("Arquivo para gravar resultados", "Arquivo de saída", "c: \ tmp \ filesFounds.note") Definir objSuperFolder = objFSO.GetFolder (folderStart)
Set fileH = objFSO.OpenTextFile(fileOutName,2 ,1)
fileH.WriteLine ("Start " & Now)
Call ShowSubfolders (objSuperFolder, fileH)
Call fileH.WriteLine ("end " & Now)
fileH.Close
Wscript.Echo "Done " & Now
WScript.Quit 0
Sub ShowSubFolders(fFolder, fileH)
On Error Resume Next
Set objFolder = objFSO.GetFolder(fFolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(objFSO.GetExtensionName(objFile.name)) = "TXT" Then
If len(objFile.name) = 9 Then
'Wscript.Echo objFile.Name
fileH.WriteLine (objFile.path)
'fileH.WriteLine (objFile.name) 'only short name
End If
End If
Next
For Each Subfolder in fFolder.SubFolders
Call ShowSubFolders(Subfolder, fileH)
Next
End Sub
Para usar o nome do arquivo deve ser a.vbs ou names5.vbs (ou qualquer outra coisa que termine com vbs), basta abri-lo - clique duas vezes ou clique com o botão direito e escolha abrir
Com o tratamento de erros, mas não tentou em c: \ (executá-lo agora)