The blog of a juvenile Geekus biologicus

Unixfu

A bin for some useful UNIX command.

Add two hours

This could be useful for nocmig fan, to ease the hour computation of a bird contact.

hour() {
    start=$1
    duration=$2
    IFS=":" read -r duration_hour duration_minute <<< $duration
    date -d "$start $(($duration_hour * 60 + $duration_minute)) minutes" +"%H:%M"
}
hour 17:00 5:43
22:43

WAV creation datetime

Here is a small snippet that demonstrates how to get the creation date-time of a WAV file with ffprobe

wav_creation_date() {
        wav="$1"
        date_key="date"
        time_key="creation_time"
        for key in $date_key $time_key; do
            ffprobe "${wav}" -v quiet -select_streams v:0 -of default=noprint_wrappers=1:nokey=1 -show_entries stream=codec_type=stream_tags=creation_time:format_tags=${key}
        done
}

Then, on the WAV file example.wav:

echo $(wav_creation_date example.wav)
2024-01-12 18:56:28