#!/bin/bash ls *jpg > filelist file=filelist fdir=".tmp_fldr_fr_renamer" if [ ! -d .tmp_fldr_fr_renamer ] then mkdir .tmp_fldr_fr_renamer else echo temp already exsist fi while [ $file == "" ] do echo "enter a file name with the script" read $file done echo "filename is $file" cat -n $file > $fdir/temp count=1 size=`cat $file | wc -l` while [ $count -le $size ] do if [ $count -lt 10 ] then cat $fdir/temp | grep ^[[:space:]][[:space:]][[:space:]][[:space:]][[:space:]]$count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new else if [ $count -lt 100 ] then cat $fdir/temp | grep ^[[:space:]][[:space:]][[:space:]][[:space:]]$count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new else if [ $count -lt 1000 ] then cat $fdir/temp | grep ^[[:space:]][[:space:]][[:space:]]$count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new else if [ $count -lt 10000 ] then cat $fdir/temp | grep ^[[:space:]][[:space:]]$count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new else if [ $count -lt 100000 ] then cat $fdir/temp | grep ^[[:space:]]$count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new else cat $fdir/temp | grep $count | sed s/$count// | sed s/^[[:space:]]*// > $fdir/new fi fi fi fi fi text=`cat $fdir/new` echo $text mv $text $count.jpg let count=count+1 done #rm -f temp #rm -f new