Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM :: Enter the drive letter of your backup drive and the path to your Onedrive folder here. %USERPROFILE% refers to your home folder
- SET driveLetter=Z
- SET onedrivePath=%USERPROFILE%\OneDrive
- REM :: Below code sets date information for folder formatting
- for /F "skip=1 delims=" %%F in ('
- wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE
- ') do (
- for /F "tokens=1-3" %%L in ("%%F") do (
- set CurrDay=0%%L
- set CurrMonth=0%%M
- set CurrYear=%%N
- )
- )
- set CurrDay=%CurrDay:~-2%
- set CurrMonth=%CurrMonth:~-2%
- set hour=%time:~0,2%
- if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
- set min=%time:~3,2%
- if "%min:~0,1%" == " " set min=0%min:~1,1%
- set secs=%time:~6,2%
- if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
- REM :: makes folder for backup; copies onedrive folder.
- set foldername="%driveLetter%:\Backups\%CurrDay%_%CurrMonth%_%CurrYear%\%hour%_%min%_%secs%\"
- mkdir %foldername%
- echo Now Backing up OneDrive...
- timeout /t 5 /nobreak >nul 2>&1
- xcopy %onedrivePath% %foldername% /I /S
- echo.
- echo.
- echo Backup Complete.
- pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement