@echo off
:: This script automates the process of launching GnuCash, waiting for it to close,
:: and then backing up its data files into a timestamped, password-protected zip file.
::
:: If you'd prefer to launch this via a Desktop Shortcut, you might want to right-click
:: it, select Properties and set it to "Run: Minimised" to keep it in the Task Bar.
:: Start GnuCash and wait until closed
echo Waiting for GnuCash to close before backing up the data . . .
start "" /d "%USERPROFILE%\Documents" /wait "C:\Program Files (x86)\gnucash\bin\gnucash.exe"
:: Backup data
set "SRC_DIR=%USERPROFILE%\Documents\GnuCash"
set "DST_DIR=X:\Storage\GnuCash"
set "ZIP_EXE=C:\Program Files\7-Zip\7z.exe"
set "PASSWORD=password123" || REM Set the 7-Zip password to encrypt the backups
:: 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%"
:: Create the destination directory if it doesn't exist
if not exist "%DST_DIR%" mkdir "%DST_DIR%"
:: Create a zip file containing all .gnucash files
"%ZIP_EXE%" a -tzip -p%PASSWORD% "%DST_DIR%\%DATE_TIME%.zip" "%SRC_DIR%\*.gnucash"
Comments
0 B
|👍
/👎
0 B
|👍
/👎
0 B
|👍
/👎