Created
November 27, 2016 21:16
-
-
Save aaccioly/f9f87334ebaf4c80882cbb1977ddff96 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Extracts Artist;Album and Title from a CSV file exported by Mp3tag | |
if [ $# -ne 1 ]; then | |
echo usage: cleanMp3tagCSV file | |
exit 1 | |
fi | |
ORIGINAL_FILE=$1 | |
#Change encoding | |
RESULT="$(iconv -f UCS-2 -t UTF-8 -c $ORIGINAL_FILE)" | |
# Select first four columns | |
RESULT="$(cut -d';' -f4-10 --complement <<< "$RESULT")" | |
# Reorder columns | |
RESULT="$(awk 'BEGIN {FS=OFS=";"} {print $2,$3,$1}' <<< "$RESULT")" | |
# Sort while keeping the first line and removing the last | |
echo $(head -n 1 <<< "$RESULT") | |
sort -t\; -k 1,1d -k 2,2d -k 3,3d <<< "$(sed '1d;$d' <<< "$RESULT")" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment