rename multiple files with rename

Rename multiple files with linux is quite easy….

With rename it is possible to rename one or more files. In the following example i renamed all pictures with the file-extension „JPG“ in „jpg“:

rename -v ’s/.JPG$/.jpg/‘ *.JPG

IMG_3425.JPG renamed as IMG_3425.jpg
IMG_3428.JPG renamed as IMG_3428.jpg
IMG_3436.JPG renamed as IMG_3436.jpg
IMG_3439.JPG renamed as IMG_3439.jpg
IMG_3440.JPG renamed as IMG_3440.jpg

With the paramter „-v“ all renamed files will be displayed in the terminal.

Resize images

Often you have to resize images from a camera for using them on a website or a gallery or if you want to send them via email.

With the following command you can easily resize images inside of a directory ( the „imagemagick“ package must be installed on your system ).

for i in *.jpg; do echo "$i"; convert "$i" -resize 25% "$i"; done

(in some shells you have to remove the “ form $i):

for i in *.jpg; do echo $i; convert $i -resize 25% $i; done

If you would like to store the resized images in a separate folder, you can use these two commands:

// create folder with name resized
mkdir resized

//resize images and store the in folder resized
for i in *.jpg; do echo $i; convert $i -resize 25% resized/$i; done

The „echo $i“ print out the files on the terminal.