See also: Heapify

Pages: 1

Rename all jpeg files by their exposure date (Bash)

I like to organise my files by when they were taken. So I wrote a script to do it for me. You will need the jhead tool installed. On Debian/Ubuntu/etc this is in the jhead package.

#!/bin/bash
 
rm renameJPEG.restore.sh
 
for file in *.jpg *.jpeg *.JPG *.JPEG; do
        if [ ! -e "$file" ]; then
                continue
        fi
        echo "Inspecting $file"
        DateTime=`jhead "$file" | grep "Date/Time"`
        FoundCount=`jhead "$file" | grep "Date/Time" | wc -l`
        if [ $FoundCount -gt 1 ]; then
                echo "Found too many results for: $file"
                continue
        elif [ $FoundCount -eq 0 ]; then
                echo "No valid headers found."
                continue
        else
            BaseFile=`echo $DateTime | awk '{ print $3 }' | tr ':' '-'`
            for i in `seq 1000`; do
                if [ ! -e "$BaseFile - $i.jpg" ]; then
                    echo "New file: $BaseFile - $i.jpg"
                    mv "$file" "$BaseFile - $i.jpg"
                    echo "mv '$BaseFile - $i.jpg' '$file'" >> renameJPEG.restore.sh
                    break
                fi
            done
        fi
done

This will rename all the files to the format YY-MM-DD - i.jpg where i is a uniquifier. Note that if you've some files with bad headers then you will get the wrong output.

...

Read more

There are no comments on this post.

Bash Script: Start irssi (or any process) if not already running via a cronjob

I know there are a thousand of these available online. This is one I just wrote and wanted to make it a thousand and one. This script will start irssi if there is no irssi process available.

Save the following script somewhere (example /home/kay/bin/irssi_init.sh) and add the following to your crontab:

*/1 * * * * /home/kay/bin/irssi_init.sh >> ~/irssi_init.log

...

Read more

There are no comments on this post.

Pages: 1

RSS
Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.