Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal EnableExtensions DisableDelayedExpansion
- set "FolderToBackup=D:\Jogos\Steam\userdata\117707557"
- set "BackupParentFolder=D:\Jogos\Steam Backup"
- set "BackupNamePrefix=userdata_"
- if not exist "%FolderToBackup%\" goto EndBackup
- rem Get region independent current date in format YYYY-MM-DD.
- for /F "tokens=2 delims==." %%I in ('%SystemRoot%\System32\wbem\wmic.exe OS GET LocalDateTime /VALUE') do set "FolderNameDate=%%I"
- set "TodayBackupFolder=%BackupParentFolder%\%BackupNamePrefix%%FolderNameDate:~0,4%-%FolderNameDate:~4,2%-%FolderNameDate:~6,2%"
- rem Was a backup folder created already today?
- if exist "%TodayBackupFolder%\" goto EndBackup
- rem Create a backup of the folder to backup by doing a simple folder copy.
- %SystemRoot%\System32\xcopy.exe "%FolderToBackup%" "%TodayBackupFolder%\" /V /C /H /I /K /Q /R /E /Y >nul
- rem Keep only the newest 5 backup folders and delete all others.
- for /F "skip=5 delims=" %%I in ('dir "%BackupParentFolder%\%BackupNamePrefix%????-??-??" /AD /B /O-N 2^>nul') do rd /Q /S "%BackupParentFolder%\%%I"
- :EndBackup
- endlocal
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement