Another mass rename script help thread


Results 1 to 5 of 5

Thread: Another mass rename script help thread

  1. #1
    Join Date
    Dec 2003
    Posts
    184

    Another mass rename script help thread

    I wrote a small bash script to convert and resize a bunch of pictures in a folder but the end resolt is picture.bmp ends up picture.bmp.jpg. Is there anyway to remove the .bmp part from the end resolt. Ive look at the sed manpages and throught the numerous rename threads posted here and my eyes are swimming and i still dont nunder stand how to get sed to do what i want. Thanks in advance.

    VoiDeR

  2. #2
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    basename?

    Code:
    $ touch blah.bmp
    $ basename ./* .bmp
    blah
    $ for i in * ; do mv "$i" "$(basename "$i" .bmp).jpg" ; done
    $ ls
    blah.jpg
    $
    Replace "mv" with whatever command you're running, make sure you're using the right syntax for it (the first "$i" is the input filename, and the quoted $(...) is the output filename), and it should work.

  3. #3
    Join Date
    Sep 2003
    Posts
    699
    If you have mogrify installed this is doable in one line (the resizing and rename) with

    mogrify -format jpg -resize 120x120! *.bmp

    where 120x120 is the new image size.
    Athlon 1.2GHz, 768MB RAM, Mandrake 10 Official, KDE 3.3.0, kernel 2.6.3-13mdk, nVidia GeForce FX5200, chaintech 7AJA2 mobo with onboard sound.

  4. #4
    Join Date
    Nov 2003
    Posts
    105
    You can use rename:
    Code:
    rename .bmp.jpg .jpg *
    This will rename *.bmp.jpg in *.jpg

  5. #5
    Join Date
    Dec 2003
    Posts
    184
    Awsome thanks alot everyone.

    Thanks
    VoiDeR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •