msgbartop
A cronological documentation test project, nothing serious, really!
msgbarbottom

15 May 2007 Shell scripts for archiving digital photos in directories by month

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: , , , , , , , , , ,

Posted by Hans-Henry Jakobsen

27 Apr 2007 What package does contain a specific file

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: , ,

Posted by Hans-Henry Jakobsen

27 Apr 2007 Get a list of all installed packages in Gentoo

equery list --installed

Tags: ,

Posted by Hans-Henry Jakobsen

10 Mar 2007 Script som viser alle installerte programmer

equery -C -q list | cut -d ' ' -f 5 | sed -n 's/-[0-9]\{1,\}.*$//p'|uniq

Tags: , ,

Posted by Hans-Henry Jakobsen

10 Mar 2007 qpkg erstattet av equery

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: , ,

Posted by Hans-Henry Jakobsen