1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Option Explicit
Dim objFSO, strDestinationFile, strSourceFolder, objFile, objFolder, objSubFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
strSourceFolder = "G:\Cao\Espagne\_Intralink_project\165-mecanisme"
strDestinationFile = "G:\Cao\Echange\tla\liste_prt_vbs.txt"
Set objFile = objFSO.OpenTextFile(strDestinationFile, 8, True) ' fichier dans lequel on écrit
'=======================================
Sub ParcourirDossier(strDossier)
Dim oFile ' relatif aux fichiers à lister
Set objFolder = objFSO.GetFolder(strDossier)
For Each oFile In objFolder.Files
' If LCase(Right(oFile.Name, 4)) = ".prt" Then
If DefExtension(oFile.name) <> "" And InStr(oFile.Name, ".prt") > 0 Then
objFile.WriteLine oFile.Path & vbTab & "Modif : " & oFile.DateLastModified
End If
Next
For Each objSubFolder In objFolder.SubFolders
ParcourirDossier objSubFolder.Path
Next
End Sub
'=======================================
ParcourirDossier strSourceFolder
objFile.Close
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
CreateObject("WScript.Shell").Run strDestinationFile, 1
Msgbox "Extraction Terminee"
'==============================================
Function DefExtension(sFile)
' Fonction pour traiter l'extension de chaque fichier comportant ".prt"
Dim pos, ext, Ret, npos
pos = InStr(1, sFile, ".")
npos = InStr(pos+3, sFile, ".")
If npos = 0 Then
Ext = Mid(sFile, pos+1, 3)
Else
Ext = Mid(Sfile, pos+1)
End If
DefExtension = Ext
End Function |
Partager