Advertisement
J2897

Start GnuCash

Jul 25th, 2024 (edited)
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.22 KB | None | 0 0
  1. @echo off
  2.  
  3. :: This script automates the process of launching GnuCash, waiting for it to close,
  4. :: and then backing up its data files into a timestamped, password-protected zip file.
  5. ::
  6. :: If you'd prefer to launch this via a Desktop Shortcut, you might want to right-click
  7. :: it, select Properties and set it to "Run: Minimised" to keep it in the Task Bar.
  8.  
  9. :: Start GnuCash and wait until closed
  10. echo Waiting for GnuCash to close before backing up the data . . .
  11. start "" /d "%USERPROFILE%\Documents" /wait "C:\Program Files (x86)\gnucash\bin\gnucash.exe"
  12.  
  13. :: Backup data
  14. set "SRC_DIR=%USERPROFILE%\Documents\GnuCash"
  15. set "DST_DIR=X:\Storage\GnuCash"
  16. set "ZIP_EXE=C:\Program Files\7-Zip\7z.exe"
  17. set "PASSWORD=password123" || REM Set the 7-Zip password to encrypt the backups
  18.  
  19. :: Get the current date and time in YYYY-MM-DD_HH-MM format
  20. for /f "tokens=2 delims==." %%I in ('wmic OS Get localdatetime /value') do set DT=%%I
  21. set "DATE_TIME=%DT:~0,4%-%DT:~4,2%-%DT:~6,2%_%DT:~8,2%-%DT:~10,2%"
  22.  
  23. :: Create the destination directory if it doesn't exist
  24. if not exist "%DST_DIR%" mkdir "%DST_DIR%"
  25.  
  26. :: Create a zip file containing all .gnucash files
  27. "%ZIP_EXE%" a -tzip -p%PASSWORD% "%DST_DIR%\%DATE_TIME%.zip" "%SRC_DIR%\*.gnucash"
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement