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

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



On Thu, Sep 15, 2011 at 10:07:16AM -0600, Aaron Toponce wrote:
> On Fri, Sep 16, 2011 at 12:03:40AM +0800, lina wrote:
> > mv *.txt  *.pdf
> >
> > can it be done * way?
> >
> > all the *.txt in current directory?
>
> Yes. Checkout the rename(1) command. It comes from Perl, and can be used
> for exactly that. Or, you could write a simple for-loop:
>
>     for FILE in *.txt; do mv $FILE.txt $FILE.pdf; done
>
> You have options.

Actually, my for-loop is bad. This is what you get for typing something
without testing.

    for FILE in *.txt; do mv "$FILE" "$(basename $FILE .txt).pdf"; done

That's better. And this time, it was actually tested. :)

--
. o .   o . o   . . o   o . .   . o .
. . o   . o o   o . o   . o o   . . o
o o o   . o .   . o o   o o .   o o o

Attachment: signature.asc
Description: Digital signature


Reply to: