script

Script to ping Technocrati

Posted on October 31, 2006. Filed under: compigiri, Computer, internet, Ping, Python, script, Technorati |

Getting your blog listed on technocrati may be a good way to increase traffic to ur site. I have written a Python script to ping technocrati with your blog details. Here is a link to the script. The script could be quite useful to automatically ping Technocrati for all your blogs using a cron job.

Python rocks 🙂

Advertisements
Read Full Post | Make a Comment ( 3 so far )

A script to remove spaces from a file name

Posted on August 1, 2006. Filed under: compigiri, Computer, script |

Removing spaces from file names

I face a lot of problem while dealing with files with spaces in their names on the Unix platform. I wrote a script yesterday to change the spaces in a file name to undescores.

It is very useful for changing the names of all files in a directory along with directory names.

Save the script to your home directory or to /usr/bin or some such directory,

Go to the directory in which you want to effect the name change and run
# find . -depth -exec ~/rename.sh {} \;

This will rename all files in the directory so that the spaces in filenames are changed to underscores.

The script is as follows:

#!/bin/bash
#
# Writen by Mayuresh Phadke (mayuresh at gmail.com)# To change the names of all files in a directory including directory names
# run the command
#
#  find . -depth -exec ~/rename.sh {} ;
#
# This command is pretty useful if you have a collection of songs or pictures transferred
# from your windows machine and you are finding it difficult to handle the
# spaces in the filenames on UNIX
#
#set -x

progname=`basename $0`

if [ $# != 1 ]
then
        echo "Usage: $progname \"file name with spaces\""
        echo
        echo "This utility is useful for renaming files with spaces in the filename. Spaces in the filename are replaced with _"
        echo "\"file name with spaces\" will be renamed to \"file_name_with_spaces\""
        echo
        exit 1
fi

old_name=$1
dir=`dirname "$1"`
file=`basename "$1"`

new_file=`echo $file|sed "s/ /_/g"`
new_name=$dir"/"$new_file

if [ "$old_name" != "$new_name" ]
then
        mv "$old_name" "$new_name"
fi

exit 0

Please let me know if you find this useful/useless or if you have any other comments about it.

Read Full Post | Make a Comment ( 23 so far )

Liked it here?
Why not try sites on the blogroll...