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
|
Function CreateFolderRecursive(FullPath)
Dim arr, dir, path
Dim oFs
Set oFs = WScript.CreateObject("Scripting.FileSystemObject")
arr = split(FullPath, "\")
path = ""
For Each dir In arr
If path <> "" Then path = path & "\"
path = path & dir
If oFs.FolderExists(path) = False Then oFs.CreateFolder(path)
Next
End Function
Sub ListDirectory(objFolder)
For Each objFile In objFolder.Files
' WScript.Echo "Fichier : " & objFile.Name
if Cdate(objFile.DateLastAccessed) <= Cdate(datearchive) then
NewFichier.WriteLine("Fichier;" & objFile.Name & ";" & objFso.GetExtensionName(objFile.Path) & ";" & objFile.Type & ";" & objFile.DateLastAccessed & ";" & objFile.DateLastModified & ";" & objFile.Path & ";" & objFile.ParentFolder & ";" & objFile.Drive &";" & MonRepdestination & Replace(objFile.ParentFolder, "C:\", "") )
' CreateFolderRecursive (MonRepdestination & Replace(objFile.ParentFolder, "C:\", "") )
' objFSO.MoveFile objFile.Path, MonRepdestination & Replace(objFile.ParentFolder, "C:\", "") & "\"
End If
Next
For Each objSubFolder In objFolder.SubFolders
'WScript.Echo "Dossier : " & objSubFolder.Name
NewFichier.WriteLine("Dossier;" & objSubFolder.Name)
ListDirectory(objSubFolder )
Next
End Sub
FichierTXT = "c:\toto.csv"
MonRepertoire = "C:\Users\xxxx\Desktop\A trier"
MonRepdestination = "D:\Archive\"
' Affectation de la date limite :
datearchive = "01/11/2017 00:00:00"
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objMyFolder = objFso.GetFolder(MonRepertoire)
Set NewFichier = objFso.CreateTextFile(FichierTXT,TRUE)
ListDirectory objMyFolder
Set objFso = Nothing |
Partager