October 22, 2015

Extracting and Organizing with Bash

Long week? Yeah, me too. I have my heavy metal Linux band in the motel room and no customers to attend to at the moment…let’s do some Bash scripting! Remember the “thumbnailing” script I did a few weeks ago? This is the script I use before doing thumbnails. It’s actually a bit more trippy and uses another script which I’ll cover in the next installment.

I begin by getting a temporary file setup:

  • #!/bin/bash
  • set -e
  • DateFile="/tmp/image-dates.$$"
  • [ -z "$DateFile" ] && echo "no datefile, bye." && exit 1
  • [ -f "$DateFile" ] && rm -f $DateFile
  • touch "$DateFile"

We have a guard: did we screw up our file name? That’s almost irrationally cautious, so you might feel justified in deleting that guard. The $$ symbol is a quick way to get your process ID (PID). You can use this for many things, but it is reasonably unique with low-frequency usage (that is, a few times a day). (Read the rest at Freedom Pneguin)

Click Here!