[NTLUG:Discuss] bash question

Wrenn, Bobby J. Bobby.Wrenn at banctec.com
Wed Sep 12 13:47:21 CDT 2001


I have been unable to get anything with spaces to work at all. Output is
truncated file name .txt with zero length files.

This seems to start to work. But it doesn't change the file name on disk
only in memory. Then it try's to work on the renamed file which doesn't
exist.

for i in ` ls *.pdf | tr ' ' '_'`; do
	DONAME=`basename $i .pdf`
	pdftotext $DONAME.pdf $DONAME.txt
done

Questions, where does "basename" come from? Is it possible the space after
"basename" is the problem?

I'm learning lots and appreciate the help.

Bobby
-----Original Message-----
From: herrold [mailto:herrold at owlriver.com]
Sent: Wednesday, September 12, 2001 12:54 PM
To: 'discuss at ntlug.org'
Subject: Re: [NTLUG:Discuss] bash question


On Wed, 12 Sep 2001, Wrenn, Bobby J. wrote:

> If I can get an answer to this I will finally be able to use Linux at
work.

... hmmm a worthy cause

> 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?

Testing a thought:

[herrold at pokey herrold]$ ls | tr ' ' '#' | grep \#
IP#and#PC#Names#for#Owl#River.rtf
[herrold at pokey herrold]$ ls I*
IHN.doc                            Image012.jpg
Interim_CEO_092799_v1.doc          IP and PC Names for Owl River.rtf

... OK -- I have a method ...

> Then how do I recursively submit the files to pdftotext with the same name
> except for the .pdf changed to .txt?

for i in ` ls *.pdf | tr ' ' '_'`; do
	DONAME=`basename $i .pdf`
	pdftotext $DONAME.pdf $DONAME.txt
done

... untested, but it should work ... test on a copy ... backup
first, etc ...

> Just getting that much done will be a big help.

-- Russ Herrold


_______________________________________________
http://www.ntlug.org/mailman/listinfo/discuss



More information about the Discuss mailing list