View Single Post
Old 11-01-2010, 12:15 PM   #5
Mixx
Zealot
Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.
 
Posts: 143
Karma: 387
Join Date: Sep 2010
Device: Kindle 3
OK, with some time on my hands, I had a crack at this on the week-end. Some of you might find this useful, others will smile how simple this whole code is. Again, I have very little skills and Windows batch files are a challenge for me. I am sure one can write this in a much more elegant way. Still, I thought some might find the script useful anyway.

The following batch file works, I tested it. I schedule it with the Windows Task scheduler, which I configure such that it wakes up the PC from hibernation, when the time has come. At the end, the code sends the PC back to hibernation. This works once a day/week, as desired.

Calibre does not have to run, the batch is self contained, with calls to two command line utilities that come with Calibre. I also use the little free utility "timer.exe" for logging (see http://www.gammadyne.com/cmdline.htm#timer).

The frequency of download is determined only by the task scheduler, i.e. independent of the times you set in Calibre itself.

Code:
@echo off

set feeds=spiegelde zeitde cio technology_review npr

set recipes=C:\Program Files\Calibre2\resources\recipes
set workdir=S:\Ebooks\News

set server=smtp.gmail.com
set port=587
set user=myuserID@gmail.com
set pwd=mypassword
set mailserver=-r %server% --port %port% -u %user% -p %pwd%

set subject=News:
set text="Calibre News Feed %DATE% %TIME%"

set from=myuserID@gmail.com
set to=myKINDLEuserID@free.kindle.com

rem ----------------------------------------------------------------

chdir /d "%workdir%

echo %DATE% %TIME% Start Calibre News Feed > news.log
echo. >> news.log

for %%a in (%feeds%) do (

  timer /nologo > nul
  start /wait ebook-convert "%recipes%\%%a.recipe" "%%a.mobi" 
  start /wait calibre-smtp %mailserver% -a "%%a.mobi" -s "%subject% %%a" %from% %to% %text%
  del "%%a.mobi"

  echo %%a >> news.log
  timer /nologo /s >> news.log
  echo. >> news.log

)

echo %DATE% %TIME% End   Calibre News Feed >> news.log

C:\Windows\system32\shutdown.exe /h

exit 0
You define the desired feeds by setting the "feeds" list. It requires the *.recipe file names (without the extension) from the corresponding Calibre folder (set on the next line for my VISTA system).

Apart from the feeds, you specify your user ID-s and the password for smtp (I use gmail above) and off you go.

I hope this helps some forum members, unexperienced on Windows like myself.

Regards, Mixx
Mixx is offline   Reply With Quote