Java applet that displays time.
Welcome on Jérôme Boismartel home page
Version française English version
Home
Home Page
My C.V.s
French C.V.
English C.V.
SysAdmin corner
Tips and tricks
Java Programs
L280 Configuration
4900Z and Linux
Barcode generation
Date conversion
Unix Scripts
Unix Monitoring
Progress Monitoring
Alarm System
My pictures
Baby pictures
-------------
England
France
Taiwan
Haiti
My links
Ressources

Unix Scripts


Renaming all files in a directory tree

Sometimes you want to rename every single files in a directory tree. I had this issue when I transfered a huge numbers of digital pictures to my linux box. I realized that Microsoft Windows was naming imported digital pictures with a space in the name making it very difficult to rename in batch.
This little script allows you to rename every single file of a directory tree including files with funny characters and spaces with filename like pictures0001.jpg.
Here is the script :

#!/bin/bash

let COUNT=0

find /home/boismarj/images/AnneAlex -name '*.jpg' -exec ls -li {} \; | sed 's/\/Picture.*.jpg//' | awk '{print $1"|"$10}' > file.txt
for lines in `cat file.txt`
do

INODE=`echo $lines | awk -F"|" '{print $1}'`
PATHTOIMG=`echo $lines | awk -F"|" '{print $2}'`

if [[ $COUNT -lt 10 ]]
then
DIGIT="00"
else if [[ $COUNT -lt 100 ]]
then
DIGIT="0"
else if [[ $COUNT -lt 1000 ]]
then
DIGIT=""
fi
fi
fi

echo $INODE --> $PATHTOIMG/image$DIGIT$COUNT.jpg
find . -inum $INODE -exec mv {} $PATHTOIMG/image$DIGIT$COUNT.jpg \;
let COUNT=COUNT+1
done

Opened window on Montréal
To contact me...
My prefered email address is jerome.boismartel@gmail.com.
St-Malo time
Java applet that displays time.
Kaohsiung time
Java applet that displays time.
Samoa time
Java applet that displays time.