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

24 Sep 2012 Rotate and rename images according to their EXIF info

This is my short script to rotate and rename image files accoring to date captured based on their EXIF info.
You need jhead and exiv2 to run this. These two programs are also available in Windows and only require you to make small changes to work there as well.

#!/bin/bash -x
echo Rotating JPEG file(s)
jhead -ft -autorot D*.JPG

echo Rename(ing) file(s)
exiv2 -r '%Y%m%d-%H%M_:basename:' rename $(ls D*)

The files are then named like this (YYYYMMDD-HHDD_OriginalFileName.extension)

20120924-1320_DSC1234.JPG
20120924-1320_DSC1234.NEF
...

This script has been tested on Nikon D80 and D7000 image files.

Tags: , , , , , ,

Posted by

02 Aug 2012 Backup of Zimbra MailBox using zmmailbox

This is a short script I use to backup the Zimbra mailbox content for my users.
This has been used on a Zimbra Collaboration Server (ZCS Open Source Edition) 7.2 installation, but should work on earlier versions as well.
I use another script to backup the whole Zimbra installation, but that might be another blog post.


#!/bin/bash -x
# Backup of Zimbra mailboxes using zmmailbox
# Restore of mailbox should be performed using:
# /opt/zimbra/bin/zmmailbox -z -m user@host postRestURL -u https://HOST "//?fmt=tgz&resolve=skip" mailbox-name-date.tgz
BackupFolder="/backup/zimbra"
MailBox="user1 user2 user3 userN"
DateToday=`date -I`
for name in $MailBox
do
sudo -u zimbra /opt/zimbra/bin/zmmailbox -z -m $name@pario.no getRestURL "//?fmt=tgz" > mailbox-$name-$DateToday.tgz
done

The backup files are named mailbox-user1-20120802.tgz mailbox-user2-20120802.tgz …

Tags: , , , , , ,

Posted by

17 Jul 2012 Rename AVCHD files using Exiftools

Simple bash script to rename AVCHD/MTS/MOV files to match their recording date and time.

#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: ./rename_video.sh FILETYPE" 1>&2
echo "Example: ./rename_video.sh *.MTS" 1>&2
exit 1
fi
for x in "$@"
do
exiftool '-FileName<DateTimeOriginal' -d %Y%m%d_%H%M_%%f.%%e "$x"
done

The resulting files will be named like YYYYMMDD_HHMM_BASENAME.ext ie 20120703_1635_05600.MTS

Exiftools can also be used to perform the renaming process in Windows as well using a command window

# exiftool "-FileName<DateTimeOriginal" -d %Y%m%d_%H%M_%%f.%%e *.MTS

This script has been tested on Canon Legria and on Panasonic HDC-SD800 video camera MTS-files and Nikon D7000 MOV-files with great success.

Tags: , , , ,

Posted by

02 Dec 2011 Grab several screenshots from specified window in linux

This was a short bash script I wrote to help document some startup problems on a server.
The script was grabbing screen dumps from iDRAC during boot on a RHEL6 server, but it can be used on other distributions as well since the console command xwd is common.

#!/bin/bash
# Description:
# Grab screenshot of a specified X-window and wait X-seconds

# Use xwininfo to find the Window id to the window you are going to 
# grab screenshots from.
xwininfo="0x4c0001a"

# filename for output
outfile="outfile-"

# seconds sleep between grabs
sleeping=2

padding="000" # put as many padding zeros as you want on filename
for ((i=0; i<1000; i+=1))
do
        # Perform the actual screenshot grab
        xwd -id $xwininfo -out $outfile-${padding:${#i}}$i.xwd

        # Convert the xwd file to a better image format like PNG
        convert $outfile-${padding:${#i}}$i.xwd $outfile-${padding:${#i}}$i.png

        # Delete the converted XWD-file
        rm -f $outfile-${padding:${#i}}$i.xwd

        # wait 
        sleep $sleeping
done

Stop the script after you have grabbed enough screenshots.

I ended up with several files named outfile-000.png outfile-001.png ...
Deleted those files that were not needed and sent the images a documentation of the booting process.

Tags: , , , ,

Posted by

10 Sep 2010 Randomize filenames

This is a simple bash script to create random filenames of all jpg-files (*.jpg) in a folder using the linux commands mv, sha1sum and cut.

#!/bin/bash
# Randomize filenames

for fname in *.jpg;
do
        mv "$fname" $(echo "$fname" | \
                sha1sum | \
                cut -f1 -d ' ' | \
                cut -b 1-5).jpg
done

The jpg-files can have names like

08df4.jpg  
1e788.jpg  
315e6.jpg  
41e19.jpg  
5f7d0.jpg  
7471e.jpg

Tags: , , ,

Posted by