Archives for April, 2011

6
Apr

Article: Playing Audio with Linux 2.4 Kernel

The 2.4 kernel seems dead to most, but it has it’s place in embedded systems. I dealt with a customer a while ago using an embedded system running the 2.4 kernel and he needed to play audio. Here’s an article that got me through the process: http://tldp.org/HOWTO/Sound-HOWTO/x504.html

4
Apr

Script to Batch Random Rename Files

I used this script the other day when I wanted to randomize a group of photos from within my current working directory in the terminal (so my digital photo frame displayed randomly instead of sequentially). You could certainly spend some extra time making this more robust, but it suited my needs. You’ll probably want to modify it a bit to suit yours.

Edit: Thanks to the commenter “thewanderer”, I revisited this script to solve the issue of duplicate $RANDOM values. Now, there’s a recursive function added so files won’t be overwritten!

#!/bin/sh

if [ $# -lt 1 ]; then
   echo "Example Usage: $0 /dev/sdb"
   exit 1
fi

DIR=$1

rename(){
   rand=$RANDOM
   if [ -f "${rand}.JPG" ]; then
      rename "$i"
   else
      mv "$i" "${rand}.JPG"
   fi
}

echo "This will rename all files randomly in $DIR"
echo -e "Continue?  ( y/n ) : c"
read answer
if [ "$answer" = "n" ] || [ "$answer" = "N" ]
then
   echo "Exiting..."
   exit 1
else
(
   cd $DIR
   for i in *.JPG; do rename "$i"; done
   cd -
) >/dev/null 2>&1 </dev/null

   echo "Files have been renamed with a random number."
fi
1
Apr

Article on Using Python to Send Email

I came across this one while I was trying to figure out a way to script sending an email. I found it to be a very useful and helpful guide and wanted to share, so here it is: http://docs.python.org/library/email-examples.html.

PS. I thought about hitting you with an April Fools joke, but I’ll spare you. ;-) Have a good one today!