Ce script permet de creer un systeme d'archive automatique avec 7zip.
Etapes :
- Reading of : C:\ArchiveLog\ArchivePath.txt ( Le script doit être placé dans le même répertoire que le fichier ArchivePath.txt )
This file contains all the path to analyze whether to extend archiving to a path that is where you can add it
- Deleting files older than 6 months in each directory.
- For the remaining files greater than two months they are zipped archive creates a directory in each directory scanned.
- The archive files greater than 6 months are deleted
- Deleting files older than 6 months in each directory.
- For the remaining files greater than two months they are zipped archive creates a directory in each directory scanned.
- The archive files greater than 6 months are deleted
Script :
@echo off @For /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @( Set DayW=%%A Set Day=%%B Set Month=%%C Set Year=%%D Set All=%%A-%%B-%%C-%%D ) @FOR /F "delims=|" %%i IN (ArchivePath.txt) DO @( mkdir %%i\ar echo "##################- %All% DELETE OLD FILES IN MAIN DIR ##########################" >> %%i\log\%All%.log Forfiles /P %%i /s /m *.* /d -180 /c "cmd /C echo @Path" >> %%i\log\%All%.log Forfiles /P %%i /s /m *.* /d -180 /c "cmd /C del @Path" echo "##################- %All% ZIP ##########################" >> %%i\log\%All%.log Forfiles /P %%i /s /m *.* /d -60 /c "cmd /C "C:\7z.exe" a -tzip %%i\log\%All%-logs.zip @Path" >> %%i\log\%All%.log Forfiles /P %%i /s /m *.* /d -60 /c "cmd /C del @Path" echo "##################- %All% DELETE OLD ARCHIVES ##########################" >> %%i\log\%All%.log Forfiles /P %%i\log /s /m *.* /d -180 /c "cmd /C del @Path" )
Aucun commentaire:
Enregistrer un commentaire