go home.

The blog of Hannibal, Missouri Artist William F. Leffert

Saturday, January 5, 2008

From Productiv: Photo Management using BASH

Here is a nice and lightweight shell script I slapped together recently (warning: it is a little rough) to help me manage my photos when I'm out on-site with the laptop, and need to backup the shots and clear my memory cards before the next set.

Note: you'll need to tweak it for your needs (for different file extensions). Usage is simple - run the script, and it'll tell you how you screwed up.

#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo enter the source directory, and the target directory - date folder will be created automatically.
exit
fi

srcdir=$1
trgdir=$2
datedir=$(date +%m%d%Y)

mkdir $trgdir/$datedir
mkdir $trgdir/$datedir/RAW
mkdir $trgdir/$datedir/jpeg
mkdir $trgdir/$datedir/etc

cp -R $srcdir/* $trgdir/$datedir/etc/

mv $trgdir$datedir/etc/*.JPG $trgdir$datedir/jpeg/
mv $trgdir$datedir/etc/*.ORF $trgdir$datedir/RAW/

That's it. Hope you find it as useful as I do.

-WFL

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home