Batch resize images with imagemagick (convert)

I am often asked how to resize a directory full of images, for free. This is definitely possible and probable there are many ways to do it, but I like to use ImageMagick for this. ImageMagick is available for almost any OS here:

Here is an example of converting a directory of JPEGs using a little scripting and imagemagick:

for i in $( ls *.jpg); do convert $i -resize 1024x768 sm_$i; done;

For loop in bash (can be used on command line or in script)

There are so many versions of Bash around and it can be frustrating, to me at least, to do some things for not knowing what is available on a given machine. Well here is one, the for loop. Here are a few different ways to do the same thing (and I am sure there are many others) . The first two below work on current linux machines but only the third works on Solaris 5.8’s version of Bash. Enjoy

for ((i=0;i<=5;i+=1));  do echo anda$i; done;
for seq 6 7;  do echo anda$i; done;
for i in 8 9 10 11 12; do cvs tag -d  anda$i; done;

use vi editor to insert newline char in replace

Something else I have to do and cannot remember and then have to look up.

In vi to insert a newline character in a search and replace, do the following:


the command above would replace all instances of “look_for” with “replace_with\n” (with \n meaning newline)

to get the “^M”, enter the key combination “ctl-V” then after that (release all keys) press the “enter” key.

Get PS to display the complete path (on Linux)

Something else I can never remember and waste time looking up is how to display long long long paths when looking at processes with “ps”. Well just a couple of “W” does the trick.

ps -auxww

More on why, later but wanted to put it down while it was fresh

set up a Debian Linux machine to handle UTF-8 in a shell or console app

To set up a Debian Linux machine to handle UTF-8 in a shell or console app do the following.

First, use dselect or whatever tool you like to find the Japanese font packages for X and install em.

Then run

  dpkg-reconfigure locales

then choose en_US.UTF-8

Test by executing the folowing in a shell:

  locale charmap

it should say


If not try just


it should have UTF-8 for everything like:


if not then Add the follwoing to .bashrc and re-source it (e.g. get a new login shell, or execute bash)

  export LC_ALL="en_US.UTF-8"

then try

locale charmap



once that is all set to UTF-8 then change your shells (xterm, rxvt) to use:

That is it. I had to exit X11 and re-login to get X11 to take these settings
so that clicking my icon for xterm launched uxterm WITH the correct environment

After this all console apps that can handle UTF-8 (like vim) display UTF-8
characters correctly.