Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 05-02-2013, 12:43 PM   #1
fxp33
Groupie
fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.
 
Posts: 199
Karma: 109220
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD... Kobo = pdf without reflow !!
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
Old 05-03-2013, 01:56 PM   #2
fxp33
Groupie
fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.fxp33 is far more humble than you.
 
Posts: 199
Karma: 109220
Join Date: Mar 2013
Location: Bordeaux, France
Device: Kobo Glo, Aura HD... Kobo = pdf without reflow !!
Linux bash (raspberry Pi)

I'm not a specialist of bash. My experiment needs enhancement.

Code:
#!/bin/bash

# http://www.mobileread.com/forums/showpost.php?p=2098144&postcount=254
cd /media/xxx/Kobo/philo_pdf
for file in *.pdf; do
#title=`cat ../../title/$file`
#title=`$file`
echo ""
echo " Title is $file"
echo ""
oldfile=$file
newfile="$file.epub"
echo " Converting: $file " 
echo ""
echo "started: $(date)"
echo ""
echo $newfile
[ ! -f "$newfile" ] && /usr/bin/ebook-convert "$file" "$file.epub" --no-default-epub-cover --no-svg-cover  --insert-metadata --authors "pdfConvert" --title "$file" || echo "$newfile already exists"
done

François
fxp33 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arc Sharing files to Mac KobosAreGreat1 Kobo Tablets 2 03-22-2013 02:37 AM
converting pdf screenplays / scripts for movies into ePUB format alanjay Calibre 15 10-07-2011 07:49 AM
Mac user needs help converting pdf's (TV Scripts) and keeping format!! mcforman Kindle Developer's Corner 12 06-20-2011 05:28 PM
Hello Need help converting files badapple Introduce Yourself 1 07-20-2007 11:57 PM


All times are GMT -4. The time now is 04:25 PM.


MobileRead.com is a privately owned, operated and funded community.