HowTo: Quick-n-dirty extraction of date inside WAV

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

HowTo: Quick-n-dirty extraction of date inside WAV

Post by peter_b »

This HowTo describes how to extract the date/time information from inside a WAVE file (.wav), in case the file timestamp was lost.
NOTE: This only works, if the recording device or application wrote the date as metadata inside the WAVE file. This must not always be the case.

This approach uses only common tools, usually available out-of-the-box on any unixoid operating system (GNU/Linux, MacOS, etc).

Here's a one-liner:

Code: Select all

$ head -c 10000 *.wav | cat -v | grep -E "20[0-9][0-9]"
NOTE: The Regular Expression "20[0-9][0-9]" only covers dates between 2000 and 2099. Adjust this accordingly.

The output may be a bit rough, since "grep" is intended for text, but now it dumps also binary data from the WAVE header:

Code: Select all

WAVEfmt ^P^@^@^@^A^@^B^@DM-,^@^@^PM-1^B^@^D^@^P^@LIST.^@^@^@INFOICRD^K^@^@^@2016.05.12^@^@ISFT^N^@^@^@Lavf57.36.100^@data^PM-^U_
Yet, you can see the date/time string (in YYYY.MM.DD notation):
2016.05.12
If you want to loop over several files, and list filename + "data block with date", you can

Code: Select all

$ for FILE in *.wav; do echo "File: $FILE"; head -c 10000 $FILE | cat -v | grep -E "201[0-9]"; echo ""; done >> date.txt
This writes the results to "date.txt".

I've used this to retrieve the date of audio recordings on deleted files, extracted using "Scalpel" - so their file timestamp was lost.
Last edited by peter_b on Mon May 23, 2016 3:37 pm, edited 1 time in total.
User avatar
peter_b
Chatterbox
Posts: 383
Joined: Tue Nov 12, 2013 2:05 am

Re: HowTo: Quick-n-dirty extraction of date inside WAV

Post by peter_b »

Another approach, with results easier to parse for further automation is, to use FFmpeg's "ffprobe" tool:

Code: Select all

$ ffprobe -v error -i $WAVE_FILE -show_format | grep -i "date"
The result per file looks like this:
TAG:date=2015.12.09
Post Reply