Re-Order Photos Using Bash

By , 12 November 2010

Re-Order Photos Using Bash

Here's a script I used to use to renumber the files in a directory according to their modification date.


# Renames the files in the current directory to a 4 digit number
# which is their position in the directory multiplied by 10.
# This script is meant to help sort photos in your albums.
# Specify a starting number on the command line if you want to start
# at another number other than zero.
# If a second number is specified, this step value is used. Otherwise
# a step value of 1 is used


for i in `ls -t .`; do
    newname=`printf "%03d" $c`.`echo ${i:${#i}-3} | tr 'A-Z' 'a-z'`
    mv "$i" $newname
    c=`expr $c + $s`
Re-Order Photos Using Bash

About Roger Keays

Re-Order Photos Using Bash

I guess I'd call myself a problem solver. Either that, or I'm some sort of organic machine designed to convert oxygen into carbon dioxide. You could go either way on that. I'm into languages and stuff. I wrote a book. It's okay, I guess. What else? I like reading, swimming, eating, and playing music. Satisfied? Sheesh.

Leave a Comment

Please visit to add your comments.