If you’ve ever worked with images on a computer you probably had to resize it in order to use it online. Here is an easy way to resize multiple images at once to a any percentage of their original sizes using the terminal in Ubuntu.

You would need some basic terminal skills to use this tutorial.

1. Open a terminal window (Ctrl-Alt-T) and change directory where your images are stored, e.g. cd Pictures/my-images.

2. Create a script called resize_images.sh and paste the following code into it:

SIZE=$1
FOLDER=${PWD##*/}
SMALLERFOLDER=../$FOLDER-$SIZE
mkdir $SMALLERFOLDER
echo 'Made a new directory to contain the resized images at '$SMALLERFOLDER

for f in `find . -regex ".*\.\(jpg\|gif\|png\|jpeg\|JPG\)"`
do
  echo "Resizing - $f to $SIZE%"
  convert $f -resize $SIZE% $SMALLERFOLDER/$f
done

3. Close the script and type ./resize_images.sh 50% into your terminal using the percantage you would prefer it to be resized to.

The script might not run due to a permissions error. To fix this, simply type chmod +x resize_images.sh into your terminal.

4. Well done! Your images should now be resized and stored in a folder at the same level as your folder that contained your images with a suffix of the percentage your resized it to, e.g. at ../my-images-50.

5. If some of your images don’t appear in the folder, check if those images’

file types are present in the list of file types in the script. You can simply add the file type to the list before the last \), e.g. \|gnf.