Created
March 17, 2023 13:38
-
-
Save ryanfb/c36b8c82a5dbcd9a6b9610c5fc03c828 to your computer and use it in GitHub Desktop.
Undo accidentally running id3tag on an M4A or M4B audio file. Assumes GNU grep and head are available at ggrep and ghead respectively (`brew install coreutils` on macOS).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OFFSET=$(ggrep --only-matching --byte-offset --max-count=1 --binary --text --perl-regexp "\x00\x00\x00\x1c" "$1" | head -1 | cut -d':' -f1) | |
tail -c +$(( $OFFSET + 1 )) "$1" | ghead -c -128 > untagged.m4b | |
if ffprobe -loglevel quiet untagged.m4b ; then | |
echo "Untagging succeeded for: $1" | |
mv untagged.m4b "$1" | |
else | |
echo "Untagging failed for: $1" | |
fi | |
rm -f untagged.m4b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment