Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- HERE=~/"SandBox/Similar"
- #.. Mount this first.
- MUSIC="/media/paul/Windows/40_Music"
- ALL="./Music.all"
- TRACK="./Track.all"
- RANK="./Track.rank"
- UNIQ="./Track.uniq"
- function Tracks {
- AWK='
- BEGIN {
- stderr = "cat 1>&2"; FS = "/";
- reBox = "[[][^]]*[]]";
- reSfx = "[.](WMA|wma|WAV|wav|MP3|mp3)$";
- }
- function Prune (tx) {
- #.. Early return for unhelpful filenames.
- #.. Like: AlbumArt_{6FE0559F-2C09-4AF7-8774-2912DC3CEDD7}_Large.jpg
- if (tx ~ /^AlbumArt.*Large.jpg$/) { ++CC["Delete Art-Large.jpg"]; return; }
- if (tx ~ /^AlbumArt.*Small.jpg$/) { ++CC["Delete Art-Small.jpg"]; return; }
- #.. Like: desktop.ini.
- if (tx !~ reSfx) { ++CC["Delete " tx]; return; }
- #.. Like: 08 Track 8.mp3
- if (tx ~ "^[0-9]*[ ]?Track [1-9][0-9]?") {
- ++CC["Delete unlabelled track"]; return;
- }
- #.. Remove generic texts before printing.
- #.. Like: 01 Love Minus Zero-No Limit.mp3
- if (sub (/^[0-9]+[ ]*/, "", tx)) ++CC["Omit track prefix"];
- #.. Like: Poetry in Motion>>.mp3
- if (sub (/[.][Mm][Pp]3$/, "", tx)) ++CC["Omit .mp3 suffix"];
- if (sub (/[.][Ww][Mm][Aa]$/, "", tx)) ++CC["Omit .wma suffix"];
- if (sub (/[.][Ww][Aa][Vv]$/, "", tx)) ++CC["Omit .wav suffix"];
- #.. Like: [Alternate Take]
- while (match (tx, reBox)) {
- ++CC["Omit " substr (tx, RSTART, RLENGTH)];
- tx = substr (tx, 1, RSTART-1) substr (tx, RSTART+RLENGTH);
- }
- print tx;
- }
- #.. Only consider filename -- last field.
- { Prune( $(NF)); }
- function End (Local, j, K) {
- asorti (CC, K);
- for (j = 1; j in K; j++)
- printf ("%8d %s\n", CC[K[j]], K[j]) | stderr;
- }
- END { End( ); }
- '
- awk -f <( printf '%s\n' "${AWK}" )
- }
- #### Script Body Starts Here.
- #.. Compare the .mp3 tracks against each other.
- [ x ] && {
- echo 1>&2 ".... Extracting MP3_Tree"
- ( cd "${MUSIC}/MP3_Tree" && find * -type f ) > "${ALL}"
- Tracks < "${ALL}" > "${TRACK}"
- echo 1>&2 ".... One-file comparison"
- time ./Sim -f -b -t 0.75 -p -w < "${TRACK}" > "${RANK}"
- uniq -c < "${RANK}" > "${UNIQ}"
- }
- #.. Compare all the .wma tracks against the .mp3 ones.
- [ x ] && {
- echo 1>&2 ".... Extracting CD_RIPS"
- ( cd "${MUSIC}/CD_RIPS" && find * -type f ) | Tracks > "./WMA.track"
- echo 1>&2 ".... Extracting MP3_Tree"
- ( cd "${MUSIC}/MP3_Tree" && find * -type f ) | Tracks > "./MP3.track"
- echo 1>&2 ".... Two-file comparison"
- time ./Sim -p -f -b -t 0.75 "./WMA.track" "./MP3.track" > "./Pair.rank"
- uniq -c < "./Pair.rank" > "./Pair.uniq"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement