[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: A quick Q: how do I command something in large amount



lina:
> 
> for i in a b c
> do
> txt2pdf -input i.txt -out i.pdf
> done

You almost nailed it:

for i in a b c ; do
  txt2pdf -input ${i}.txt -out ${i}.pdf
done


Instead of listing the files manually, you can use '*' as a wildcard.
But that only works if your filenames don't contain whitespace. A more
robust solution:

find /dir/to/files -type f -print0 | \
    xargs -0 -I§ txt2pdf -input § -out §.pdf

This will produce filenames like "a.txt.pdf", but you get the idea.
xargs hast the additional benefit that you can use multiple cores at
once when using the -P option.

J.
-- 
Tony Blair is a hypnotised self-seeking scarecrow just like all the
rest.
[Agree]   [Disagree]
                 <http://www.slowlydownward.com/NODATA/data_enter2.html>

Attachment: signature.asc
Description: Digital signature


Reply to: