View Single Post
Old 05-02-2013, 12:43 PM   #1
fxp33
Addict
fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.fxp33 figured out that Keyser Söze was the Kevin Spacey character in less than 20 minutes.
 
Posts: 261
Karma: 110864
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD, kindle paperwhite
Sharing your scripts for converting files

Hi,

I have found a few threads with parts of script in different languages, but not one regrouping complete scripts (maybe I'm wrong).

I'd be happy to see what some of you have come up with.

Here are mine:

pdf to Epub (ms-Dos on winXP)

Code:
setlocal enableextensions enabledelayedexpansion
for /R "D:\_D\_01avril2013\ebooks\husserl" %%G IN (*.pdf)  DO (
	echo "%%~nG"
		if not exist "%%G.epub" "D:\PortableApps\Calibre Portable\Calibre\ebook-convert.exe" "%%G" "%%G.epub" --authors "Husserl" --title "%%~nG" --no-default-epub-cover --language "fr" --enable-heuristics -v
)
endlocal
  • the adress of the root directory is manually entered
  • loops inside sub directories
  • title = file name without extension
  • works with accented filenames although it looks jammed inside the concole


Doc to epub (ms-dos, libreoffice, xp)
Actually, the epub plugin of libreoffice works a lot better than this script (although if your doc file has drawings - not picture, drawings - it gets stuck)
But the plugin needs opening each file one at a time (I think)

This second example is a conversion in two steps:
  1. doc to rtf using libre office
  2. rtf to epub using calibre

Code:
REM chcp 1252
setlocal enableextensions enabledelayedexpansion
for /R "D:\_organised\_etexts\_philosophy\docs" %%G IN (*.doc)  DO (

		if not exist "%%~nG.rtf"	"D:\PortableApps\LibreOfficePortable\App\libreoffice\program\soffice.exe" --headless --convert-to rtf --outdir "D:\_organised\_etexts\_philosophy\docs" "%%G"
)

for /R "D:\_organised\_etexts\_philosophy\docs" %%G IN (*.rtf)  DO (

		if not exist "D:\_organised\_etexts\_philosophy\docs\%%~nG2.epub" "D:\PortableApps\Calibre Portable\Calibre\ebook-convert.exe" "%%G" "D:\_organised\_etexts\_philosophy\docs\%%~nG2.epub" --authors "Fxp33" --title "Philo : %%~nG" --no-default-epub-cover --no-svg-cover --language "fr" -v
)
endlocal
  • tried messing up with chcp for unicode filenames... no success yet
  • I usually check if a conversion has already bin made: usefull if you have stopped a 1000 files loop: it goes where it stopped before
  • When I already have epubs in the destination directory, I give a piece of text in the extension to distinguish the converted ones, from the "official ones". Easier to delete them all if something went wrong.
  • I don't like the default Calibre cover picture... maybe a mistake because my reader takes the first page as image, and usually the title is unreadable


I know there are lots of ways for python and perl to play along directly with Calibre. I hope someone will share their tips.

Perl, xp (accented filenames)

All the filenames are jammed for me.
And I also had problem sending mutliple arguments from console to perl (and between perl programmes)

The only solution I found was:
  • loop throup directories and take filenames for conversion
  • doing the regexp magic for extracting the information I need
  • writing the msdos conversions command lines in a .bat file
  • starting the .bat file in dos console

Hope this helps

François
fxp33 is offline   Reply With Quote