aboutsummaryrefslogtreecommitdiff
path: root/musicSorter.sh
blob: cf65400d15a58ec89eeb23b8258ec8d2fbb173fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

count=0
files="${1}/*.mp3"
for file in $files; do
	count=$(($count+1))
	echo "File $count: $file" >> "$1/filelist.txt"
	artist=$(tagmp3 show "$file" | grep "Artist" | cut -d' ' -f7- | xargs)
	if [ -n "$artist" ]; then
		if [ -z "$(ls $1 | grep "$artist")" ]; then
			mkdir -p "$1/$artist"
		fi
		target="$1/$artist/$(basename "$file")"
		mv -f "$file" "$target"
	fi
done