A. Racine aracine at u.washington.edu
Mon May 22 21:00:43 PDT 2000

This one only fits your description if you allow for semicolons.

$ ls
one three two
$ mkdir /tmp/flarf ; cp * /tmp/flarf ; mv -f -b -S .png
/tmp/flarf/* . ; rm -f *[^.png] ; rmdir /tmp/flarf ; rm -f png
$ ls
one.png three.png two.png

that last 'rm -f png' is just incase you had a file named png, and you
wanted it moved to png.png. Without it, you'll be left with:

one.png png png.png three.png two.png

since *[^\.png] matches the file 'png' (despite the \.), so it won't get

If you use bash or sh, you could use

for file in *; do mv $file $file.png; done


On Mon, 22 May 2000, R. David Whitlock wrote:

# ok, here's a quickie:
# how would you rename all files in a directory to the same name plus an
# extension on the command line?
# for example, if I have 12 files named "1" "2" "3", etc, how to turn them
# all into "1.png" "2.png" "3.png", etc?
# -david

More information about the Linux mailing list