46 lines
1.1 KiB
Org Mode
46 lines
1.1 KiB
Org Mode
|
#+title: Unixfu
|
||
|
#+date: <2024-01-14 Sun>
|
||
|
#+category: linux
|
||
|
|
||
|
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.
|
||
|
|
||
|
#+begin_src bash
|
||
|
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
|
||
|
#+end_src
|
||
|
|
||
|
#+RESULTS:
|
||
|
: 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=
|
||
|
|
||
|
#+begin_src bash
|
||
|
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
|
||
|
}
|
||
|
#+end_src
|
||
|
|
||
|
Then, on the WAV file =example.wav=:
|
||
|
#+begin_src bash
|
||
|
echo $(wav_creation_date example.wav)
|
||
|
#+end_src
|
||
|
|
||
|
#+begin_example
|
||
|
2024-01-12 18:56:28
|
||
|
#+end_example
|