> Say, I have photo_1.jpg, photo_2.jpg ... photo_500.jpg in a directory.
> 
> Is there a fast way to rename these files to 001.jpg, 002.jpg 
> ... 500.jpg?

for old in directory/photo*; do new=`echo $old | sed 's/photo_//g'`; mv -v $old $new; 
done

Would give you 1.jpg, 2.jpg...500.jpg. If you display those with Apache, try 
IndexOptions VersionSort which I think should display them in the correct order. If 
you really want 001, 002.. etc that's possible too, but harder:

for old in directory/photo*; do new=`echo $old | sed 's/photo_//g;s/\.jpg//g' | xargs 
printf "%03d.jpg"`; mv -v $old $new; done

-- 
TONI HEINONEN
     TELEWARE OY
     +358 40 836 1815 / +358 (9) 3434 9110
     It?keskuksen Maamerkki
     00930 Helsinki, Finland
     [EMAIL PROTECTED] / www.teleware.fi
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to