Loading...
 

PdfToText

With Zaufi's new TikiIntegrator I realized that I've got a lot of pdfs that I'd like to convert for my Tiki site so I'm wrestling with this bash script using pdftotext

Any help would very much be appreciated!

redflo and zaufi both helped out here... this is the script that worked from the mnt/crdom1 directory

for i in `find -name '*.pdf'`; do pdftotext -layout $i ~/convertedpdfs/$i.txt; done

Next time I'll mv the files first... but it worked like a charm! Now to add the script around it so I can reuse it ad nauseum...

biggrin

The script will be used multiple times on different CDs of PDFs

script name =
convertpdftotext.sh

!/bin/bash
######################
#setup variables
#####################################################################
PDFDIR=' /mnt/cdrom1/PDFs/'
#####################################################################
# Convert pdf files to text
####################################################################
cd ${PDFDIR}
for files in $PDFDIR -type f -name "*.pdf" -exec echo pdftotext {} --layout ~/convertedpdfs {}.txt \;
#############################
#I need to tell it to look for *.pdfs but not sure how to do that
#Maybe for *.pdf files in ${PDFDIR}???
do
        if [ -f $

		

]; then echo converting $

>>/tmp/convertedpdfs #<-------- I like seeing what's happening pdftotext $

--layout $

.txt >>~/convertedpdfs done

------------
I'm getting errors:
converpdftotext.sh: line 1: !/bin/bash: No such file or directory
converpdftotext.sh: line 19: syntax error near unexpected token `done'
converpdftotext.sh: line 19: `done'
----------

or this one?

####################################
#!/bin/bash
#####################################################################
# setup variables
#probably need to set a variable for the PDF files
#####################################################################
PDFDIR=' /mnt/cdrom1/PDFs/'
FILE=*.pdf #<--------I don't think that's it :(
#copy it
cp /mnt/cdrom1/PDFs/$FILE ~/tmp/PDF

#do  processing here
for f in $*{PDFDIR}
do
  mv $f $N.pdf
  pdftotext -layout $N
  echo $f renamed into $N.txt #<-------- I like seeing what's happening
done
exit 0
############################ 

Page last modified on Sunday 09 November 2003 23:53:25 GMT-0000