Results 1 to 2 of 2

Thread: Preserving filenames in ImageMagick

  1. #1
    Join Date
    Aug 2007
    Location
    hampshire
    Beans
    10
    Distro
    Ubuntu

    Preserving filenames in ImageMagick

    Is there a way of using convert so that it will preserve filenames in a batch conversion. I have tried

    Code:
    convert *.bmp *.png
    as suggested in another thread, but it merely outputs the files as *-1.png, *-2.png, etc.

    Also, is there a way of getting convert to work on subfolders?

  2. #2
    Join Date
    Jun 2008
    Location
    California
    Beans
    2,271
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Preserving filenames in ImageMagick

    Quote Originally Posted by Tetenterre View Post
    Is there a way of using convert so that it will preserve filenames in a batch conversion....
    You can use the mogrify command-line utility to convert a series of image files to another format with the same base file name. To do this, open a terminal window and change to the directory that contains the image files. Then, enter the following:

    Code:
    mogrify -format png *.bmp
    As you are probably aware, mogrify is a part of the imagemagick suite and performs essentially the same functions as the convert utility. The above command does not overwrite or change the original files in any manner.

    If you still want to use the convert utility, the following command line will do what you want:

    Code:
    for file in *.bmp ; do convert "$file" "${file/%bmp/png}" ; done
    As always, test the above on some files to make sure all works as expected.
    Last edited by kaibob; December 6th, 2008 at 06:52 PM.

Tags for this Thread

Bookmarks

Posting Permissions

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