are 1-130 dirs the only things in /mp3?
Code:
#!/bin/bash
src=$HOME/temporary
dest=$HOME/mp3
# $src/number/album/title ~ artist.mp3
for f in "$src"/*/*/*.mp3
do
printf "$(( ++i )): "
artist=${f%.mp3}; artist=${artist##*\~ } # extract artist from filename
album=${f%/*.mp3}; album=${album##*/} # extract album from path
mkdir -p "$dest/$artist/$album" # create dest dir for file (cp/mv requires existing target dir)
echo mv -v "$f" "$dest/$artist/$album" # cp if copying original data, mv if sorting files dumped to internal hdd
done
copy files first to a temporary location and then try the script above (set proper paths), which should sort files how you want
In its current form the script should print a bunch of mv -v <file> <dest_dir> (echo) so you can check if everything is ok, if you like what you see remove echo to actually execute mv's to put files in proper places.
You can use the script to copy data from the original location right off the bat, your choice (but then you need cp not mv)
Bookmarks