johnsu01 (johnsu01) wrote,
johnsu01
johnsu01

Change the Extensions of Multiple Files

This example changes the extensions of all the files in the current directory that end in .html to .txt.

for a in *.html; do mv "$a" "$(echo "$a" | sed 's/html$/txt/')"; done

So, to convert all of the .jpg's in a directory to .xpm's, which I needed to do in order to set up a library\ of .xpm background images for my aterm to randomly choose from, do:

for a in *.jpg; do convert "$a" "$(echo "$a" | sed 's/jpg$/xpm/')"; done

Tags: script, shell
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments