[Graphic] [Howto] [Linux] [Photography] [Programming] [Tips and Tricks]
Linux tip: Rename and resize images with bash script from console
Don't want to miss a single bit? Subscribe to our RSS Feed!
Do you have a big collection of images? Do you want to prepare them for publishing on the web, sending on email or any other purpose? In Linux robust graphic applications are not needed for renaming and resizing a lot of images. Linux have simple solution, a simple bash script can the job.
Here is the bash script:#!/bin/sh
Save the script in a file called picturework.sh and make it executable with
counter=1
root=mypict
resolution=400x300
for i in `ls -1 $1/*.jpg`; do
echo "Now working on $i"
convert -resize $resolution $i ${root}_${counter}.jpg
counter=`expr $counter + 1`chmod u+x picturework.sh
and store it somewhere in your path. Now, if you have a bunch of .jpg files in the directory /path/to/dirpic, all you have to do is to executepicturework.sh /path/to/dirpic
and in the current directory you'll find mypict_1.jpg, mypict_2.jpg etc, which are the resized versions of your original ones. You can change the script according to your needs.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or Subscribe to Feed and get articles like this delivered automatically to your Email or feed reader.
2 comments:
Keep in mind to run convert the imagemagick package needs to be compiled.
might need a "done" at the end of the script. (bash)
Post a Comment