[NTLUG:Discuss] bash question

Michael Patrick michael at techiesplace.com
Wed Sep 12 12:41:38 CDT 2001


I *think* this should work for you (test it first...)

for x in *.pdf ; do pdfapp "$x".pdf `ls "$x".pdf | sed -e "s/pdf/txt/g` ; done

(note that the s/pdf/txt/g regexp will match any hit of pdf)

I don't know the commands for the pdfapp, so the above is just a sample.  On the mass renaming:

for x in *.* ; do mv "$x" `ls "$x" | sed -e "s/ /_/g"`; done


What this does is take every file in the directory and moves it the same name, but with underscores instead of spaces.

Michael

On Wed, Sep 12, 2001 at 11:40:56AM -0500, 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



More information about the Discuss mailing list