Sunday, June 6, 2010

Personality Development

When the earth celebrated it's 2010 th birthday, my dad gave presented me a set of six books. All the books were authored by the immortal soul, Swami Vivekananda. The essence of those six books was "How should youth develop their personality".

Vivekanada urges all the youth of India, to spend quality time in improving their personality. Here personality doesn't mean looking smart, handsome alone. He takes a holistic approach on defining personality. He states, a youth should be physically fit, mentally fit and spiritually fit. Of course, most know what physically fit means. I will be writing more on the mental and spiritual part.

Staying mentally fit means being without worries. Worry is like a rocking chair. It will keep you occupied but will take you nowhere. Worry clouds your thinking and the grosser effect of it is very less concentration on the job you are doing at present. Eg. When I open a book, I start reading it with full concentration for 5 mins, then it starts slowly to decline. At some point of time, my eyes will be rolling over the text, but my thoughts and concentration will be somewhere. These are the grosser effects of some things that are subtly wrong within our selves. To go into the exact subtler causes will take up a lot of space for me. (to be contd.....)


Saturday, March 6, 2010

Removing Spaces from file names

Recently I came across an interesting problem. I had photos of a recent trip in the directory pictures. The name of the files were as follows.

Image DSCN 10101
Image DSCN 10102
Image DSCN 10103
Image DSCN 10104

All the images were of the .JPG format. The size of each image was around 2.0 MB. Since I wanted it to upload it on the net, I decided to increase the compression level of the jpeg image using the convert command. I had around 70 files to be changed. I wrote a simple shell script to do this.


#!/bin/bash
for file in `ls -1`
do
convert -quality 50 $file new-$file
echo $file
done

I wrote this loop to iterate over all the file inside the pictures directory. I was taken by suprise when I ran this shell script. I got numerous errors. I found out that the variable file uses space as a de-limiter. Since the file name contains spaces, the complete name of the file was not in the $file variable. So first I had to remove the spaces in the file names of the pictures. I googled around and came across this handy command called rename.

The rename command is used to rename a file according to a perl kind of regular expression. To tackle my problem, the command used was,

$rename 's/ *//g' *.JPG

The above command searches for any white spaces in the file names. If present, it replaces it by null string. The syntax is similar to the search and replace syntax used in vi.
hit counter