View Single Post
Old 03-08-2016, 12:15 PM   #6
badbob001
Fanatic
badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.
 
badbob001's Avatar
 
Posts: 556
Karma: 1102020
Join Date: Sep 2009
Device: Kindle Keyboard (rip), Kindle Voyage, Fire Tablet 10 '17, iPad '19
Thanks Kovid!

Quote:
Originally Posted by Dopedangel View Post
Could you share the script now that Kovid has made the changes.
Let me clarify what my workflow is like:
  1. An autohotkey script is alway running checking to see if Calibre is running.
  2. 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.
  3. When I exit Calibre, the autohotkey script will know that and then:
    1. Check if there is an update in the Downloads folder. If yes, run it.
    2. 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:
  1. 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).
  2. Start Calibre.
badbob001 is offline   Reply With Quote