@echo off
setlocal
Β
REM This is a backup script I've designed solely for use with the Ditto clipboard manager.
Β
:: Instructions:
:: To schedule this script to run monthly using the Windows Task Scheduler:
:: 1. Open Task Scheduler.
:: 2. Click "Create Basic Task..." in the Actions pane.
:: 3. Name the task and provide a description, then click "Next".
:: 4. Select "Monthly" and click "Next".
:: 5. Set the desired start date_time and time, choose all of the months and the day, then click "Next".
:: 6. Select "Start a program" and click "Next".
:: 7. Click "Browse..." and select this script file.
:: 8. Click "Next" and then "Finish".
Β
:: Paths
set "DITTO_PATH=C:\Program Files\Ditto\Ditto.exe"
set "DITTO_DB_PATH=%USERPROFILE%\AppData\Roaming\Ditto\Ditto.db"
set "BACKUP_PATH=X:\Storage\Ditto"
set "ZIP_EXE=C:\Program Files\7-Zip\7z.exe"
set "PASSWORD=password123" || REM Set the 7-Zip password to encrypt the backups
Β
:: Disconnect and exit Ditto using command line
"%DITTO_PATH%" /Disconnect
timeout /t 3 /nobreak >nul
"%DITTO_PATH%" /Exit
Β
:: Alert the user
echo Ditto backup initiated. Do not use. This will only take a few seconds.
timeout /t 10
Β
:: Close Ditto
:waitloop
taskkill /im Ditto.exe
timeout /t 1 /nobreak >nul
tasklist /fi "imagename eq Ditto.exe" | find /i "Ditto.exe" >nul
if not errorlevel 1 (
Β Β goto waitloop
)
Β
:: Get the current date and time in YYYY-MM-DD_HH-MM format
for /f "tokens=2 delims==." %%I in ('wmic OS Get localdatetime /value') do set DT=%%I
set "DATE_TIME=%DT:~0,4%-%DT:~4,2%-%DT:~6,2%_%DT:~8,2%-%DT:~10,2%"
Β
:: Backup Ditto database file with password
"%ZIP_EXE%" a -tzip -p%PASSWORD% "%BACKUP_PATH%\%DATE_TIME%.zip" "%DITTO_DB_PATH%"
Β
:: Check if backup was successful
if exist "%BACKUP_PATH%\%DATE_TIME%.zip" (
Β Β :: Delete the original database file
Β Β del "%DITTO_DB_PATH%"
Β Β timeout /t 10
) else (
Β Β echo Backup failed, original file not deleted.
Β Β pause
Β Β exit /b 1
)
Β
:: Reopen Ditto
start "" "%DITTO_PATH%"
timeout /t 3 /nobreak >nul
"%DITTO_PATH%" /Connect
Β
Comments
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π
0 B
|π
/π