This is my version of the shell script “Shell scripts for archiving digital photos in directories by date“. It utilizes the exiftags command available in most linux distributions like Gentoo and debian Linux. Though the metacam program is also usefull since it can read Nikon NEF-files.
Here’s an example of a directory tree they create:
2006
2006-10
IMG_48324.JPG
IMG_48325.JPG
IMG_48326.JPG
IMG_48331.JPG
IMG_48333.JPG
IMG_48334.JPG
IMG_48337.JPG
2006-11
IMG_48338.JPG
...etc...
move-digiphotos
This bash script (move-digifotos) scans EXIF tags from .JPG files in current directory with metacam, creates necessary directories under $BASEDIR and moves the files in them:
#!/bin/bash
# Reads EXIF creation date from all .JPG files in the
# current directory and moves them carefully under
#
# $BASEDIR/YYYY/YYYY-MM/YYYY-MM-DD/
#
# ...where 'carefully' means that it does not overwrite
# differing files if they already exist and will not delete
# the original file if copying fails for some reason.
#
# It DOES overwrite identical files in the destination directory
# with the ones in current, however.
#
# This script was originally written and put into
# Public Domain by Jarno Elonen ; in June 2003.
# Feel free to do whatever you like with it.
BASEDIR=/home/backup/test
find -maxdepth 1 -name "*.JPG" | while read x; do
DATE=`exiftags "$x" | \
egrep "^[ t]*Image Created:" | \
sed -r "s/Image Created: ([0-9:]*).*/\1/"`
if [ ! -z "$DATE" ];
then
YEAR=`echo $DATE | sed -r "s/([0-9]*):([0-9]*):([0-9]*)/\\1/"`
MONTH=`echo $DATE | sed -r "s/([0-9]*):([0-9]*):([0-9]*)/\\2/"`
if [ "$YEAR" -gt 0 ] & [ "$MONTH" -gt 0 ]
then
INSTDIR=${BASEDIR}/${YEAR}/${YEAR}-${MONTH}
install -d "$INSTDIR"
INSTFILE="$INSTDIR/$x"
if [ -e "$INSTFILE" ] && ! cmp -s "$x" "$INSTFILE"
then
echo "WARNING: '$INSTFILE' exists already and is different from '$x'."
else
echo "Moving '$x'"
cp -ax "$x" "$INSTFILE"
if ! cmp -s "$x" "$INSTFILE"
then
echo "WARNING: copying failed somehow, will not delete original '$x'"
else
rm -f "$x"
fi
fi
else
echo "WARNING: '$x' doesn't contain date."
fi
else
echo "WARNING: '$x' doesn't contain date."
fi
done
Tags: backup, bash, Debian, egrep, exiftags, find, Gentoo, JPG, metacam, NEF, sed
Posted by Hans-Henry Jakobsen
Earlier in Gentoo, qpkg could have been used to do this query, but it’s deprecated and equery is now the right tool.
Find out witch package the command netstat belongs to:
equery belongs /bin/netstat
Tags: equery, Gentoo, qpkg
Posted by Hans-Henry Jakobsen
equery list --installed
Tags: equery, Gentoo
Posted by Hans-Henry Jakobsen
equery -C -q list | cut -d ' ' -f 5 | sed -n 's/-[0-9]\{1,\}.*$//p'|uniq
Tags: equery, Gentoo, sed
Posted by Hans-Henry Jakobsen
Tidligere kunne man spørre om hvilket program som eier f.eks fila /etc/init.d/dhcpd vha:
qpkg -f /etc/init.d/dhcpd
Denne kommandoen eksisterer ikke lengre så nå må man kjøre kommandoen:
equery b /etc/init.d/dhcpd
Tags: equery, Gentoo, qpkg
Posted by Hans-Henry Jakobsen