[NTLUG:Discuss] bash question

Frank Lewis Jr. frank.lewis at netzero.net
Wed Sep 12 13:01:20 CDT 2001


#!/bin/bash

for i in `ls *.pdf | awk -F. '{print $1}'` ; do
# This section removes the spaces from the filenames
 	file=`echo $i | sed -e s/\ //g`
 	mv "$i.pdf" $file.pdf
 	i=`echo $file`
# This section handles the pdf2text stuff.
	pdf2text "$i.pdf" > "$i.txt"
# Not sure if you have to escape the quotes here or
# not. If so uncomment the line with  \'s and comment
# out the previous pdf2text line.
#	pdf2text \"$i.pdf\" > \"$i.txt\"
done

# You may need to correct the usage of the pdf2text 
# command. I've never used pdf2text before, but the 
# variable declariations should be exactly what you 
# are looking for.

#-Frank


-----Original Message-----
From: discuss-admin at ntlug.org [mailto:discuss-admin at ntlug.org] On Behalf
Of George Lass
Sent: Wednesday, September 12, 2001 12:25 PM
To: discuss at ntlug.org
Subject: Re: [NTLUG:Discuss] bash question

On newer versions of RedHat (7.1 anyway) you can also escape the
space(s):

"file name with spaces.pdf"

file\ name\ with\ spaces.pdf

George


"Wrenn, Bobby J." wrote:
> 
> If I can get an answer to this I will finally be able to use Linux at
work.
> 
> I need to take 209 pdf files with spaces in the file names. and
convert them
> into text. I am very new to scripting and know nothing about regular
> expressions. Is there an easy way to remove the spaces from the file
names?
> Then how do I recursively submit the files to pdftotext with the same
name
> except for the .pdf changed to .txt?
> 
> Just getting that much done will be a big help. The next step may be
> trickier. I need to extract a name, address, and equipment list from
each of
> the files and get it into some kind of database where I can query for
total
> by item or item by location.
> 
> I'm a database beginner but a quick learner. TIA for any help. Please
> contact me directly if this is not appropriate for the list.
> 
> TIA
> Bobby Wrenn
> Sr. Service Planner
> BancTec, Inc.
> 972.450.7832
> 
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss




More information about the Discuss mailing list