Thanks Kovid!
Quote:
Originally Posted by Dopedangel
Could you share the script now that Kovid has made the changes.
|
Let me clarify what my workflow is like:
- An autohotkey script is alway running checking to see if Calibre is running.
- When I run Calibre, I may get an update notice. If I like, I click the link and download the update to my Downloads folder.
- When I exit Calibre, the autohotkey script will know that and then:
- Check if there is an update in the Downloads folder. If yes, run it.
- Backup my library files to my NAS.
autohotkey script:
Code:
loop {
process, wait, calibre.exe
Process, waitclose, calibre.exe
Run, %comspec% /c "D:\Users\myname\Desktop\docs\Backup Libary.cmd"
}
backup library.cmd:
Code:
@echo off
echo Backup will occur in 10 seconds...
ping -n 10 127.0.0.1>nul
set downloadpath=D:\Users\myname\Downloads
set portablepath=d:\_Library\Calibre Portable
set found=
set upgrade=
FOR /f "tokens=1,2 delims=[] " %%a IN ('dir /od /b "%downloadpath%\calibre-portable-installer-*.exe" ^| find /n /i ".exe"') do set found=%%a& set upgrade=%%b
echo [%found%][%upgrade%]
if not "%found%"=="" call:upgradingcalibre
robocopy /np /mir /dcopy:t /copy:dat /zb /r:5 /w:60 /tee /log:"%~n0.log" "%portablepath%" "\\mynas\g\Books\_Library\calibre\Calibre Portable"
ping -n 10 127.0.0.1>nul
echo %date% %time%>"d:\_Library\daughtername_calibre\update.txt"
robocopy /np /mir /dcopy:t /copy:dat /zb /r:5 /w:60 /tee /log+:"%~n0.log" "d:\_Library\daughtername_calibre" "\\mynas\g\Books\_Library\daughtername\daughtername_calibre"
ping -n 10 127.0.0.1>nul
echo %date% %time%>"d:\_Library\myname_calibre\update.txt"
robocopy /np /mir /dcopy:t /copy:dat /zb /r:5 /w:60 /tee /log+:"%~n0.log" "d:\_Library\myname_calibre" "\\mynas\g\Books\_Library\myname\myname_calibre"
ping -n 10 127.0.0.1>nul
goto:EOF
:upgradingcalibre
REM This is no longer needed: autohotkeyscript-to-click-no-to-calibre.ahk
"%downloadpath%\%upgrade%" "%portablepath%"
ping -n 10 127.0.0.1>nul
del /q "%downloadpath%\calibre-portable-installer-*.exe"
goto:EOF
Copying my local library to the NAS is for backup purposes and also allows my daughter to download the latest changes to her computer. Calibre is compatible with being shared over the network and this syncing method is what I use to make it work.
You may wonder what is the point of putting the backup date/time into the update.txt file. On my daughter's computer, calibre is started with a batch script that:
- Compares the local update.txt with the update.txt on the NAS. If they are different, then use robocopy to download the changes (includind the latest update.txt file).
- Start Calibre.