Code BATCH
Fermé
eljojo_e
Messages postés
1155
Date d'inscription
lundi 10 mai 2010
Statut
Membre
Dernière intervention
14 octobre 2022
-
29 nov. 2011 à 11:47
eljojo_e Messages postés 1155 Date d'inscription lundi 10 mai 2010 Statut Membre Dernière intervention 14 octobre 2022 - 29 nov. 2011 à 15:07
eljojo_e Messages postés 1155 Date d'inscription lundi 10 mai 2010 Statut Membre Dernière intervention 14 octobre 2022 - 29 nov. 2011 à 15:07
A voir également:
- Code BATCH
- Code asci - Guide
- Fichier batch - Guide
- Code puk bloqué - Guide
- Code telephone oublié - Guide
- Code blocks free - Télécharger - Langages
2 réponses
Lord Zero
Messages postés
459
Date d'inscription
lundi 18 octobre 2010
Statut
Membre
Dernière intervention
15 juin 2018
115
29 nov. 2011 à 12:50
29 nov. 2011 à 12:50
En batch, je trouve sa relou par contre en VBS c'est sympa.
les parties en gras sont a modifier.Tu peux l'excuter avec une commande dans ton batch. Il scan dossier, sous-dossier, sous sous-dossier...
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2" ) Set objFSO = CreateObject("Scripting.FileSystemObject" ) Set objShell = CreateObject("Shell.Application" ) strFolderName = ("Chemin du dossier") Set colSubfolders = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _ & "Where AssocClass = Win32_Subdirectory " _ & "ResultRole = PartComponent" ) arrFolderPath = Split(strFolderName, "\" ) strNewPath = "" For i = 1 to Ubound(arrFolderPath) strNewPath = strNewPath & "\\" & arrFolderPath(i) Next strPath = strNewPath & "\\" Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile where Path = '" & strPath & "'" ) For Each objFile in colFiles Set objReadOnlyFile = objFSO.GetFile(objFile.Name) 'Wscript.Echo objFile.Name & chr (10) & objReadOnlyFile.DateLastModified if DateDiff("d",objReadOnlyFile.DateLastModified ,Date)>nombre de jour then objFile.delete end if Next For Each objFolder in colSubfolders GetSubFolders strFolderName Next Sub GetSubFolders(strFolderName) Set colSubfolders2 = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _ & "Where AssocClass = Win32_Subdirectory " _ & "ResultRole = PartComponent" ) For Each objFolder2 in colSubfolders2 strFolderName = objFolder2.Name arrFolderPath = Split(strFolderName, "\" ) strNewPath = "" For i = 1 to Ubound(arrFolderPath) strNewPath = strNewPath & "\\" & arrFolderPath(i) Next strPath = strNewPath & "\\" Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile where Path = '" & strPath & "'" ) For Each objFile in colFiles Set objReadOnlyFile = objFSO.GetFile(objFile.Name) if DateDiff("d",objReadOnlyFile.DateLastModified ,Date)>)>nombre de jour then 'Wscript.Echo objFile.Name & chr (10) & objReadOnlyFile.DateLastModified objFile.delete end if Next GetSubFolders strFolderName Next End Sub
les parties en gras sont a modifier.Tu peux l'excuter avec une commande dans ton batch. Il scan dossier, sous-dossier, sous sous-dossier...
eljojo_e
Messages postés
1155
Date d'inscription
lundi 10 mai 2010
Statut
Membre
Dernière intervention
14 octobre 2022
152
29 nov. 2011 à 15:07
29 nov. 2011 à 15:07
Wo merci pour ce code, mais je n'y comprends strictement rien (et j'aime bien comprendre ^^) , je fais un petit de batch et connais pas mal le vba sur excel et access mais ca je ne comprends pas ^^
Y aurait-il pas un moyen de gérer les dates en batch ?
Y aurait-il pas un moyen de gérer les dates en batch ?