0

I'm trying to use Cygwin to re-organize my music folder. Currently it's in iTunes format

{Artist}/{Album}/Song ##.mp3

I want to copy the album folders up to the parent folder and add the artist name, so

~/{Artist}/{Album} becomes ~/{Artist} - {Album}

but I am having trouble writing a script that works. Tried this:

for i in ~/music/*; { mv $i ~/'basename - $i';}

to no avail. Any help? Thanks!

1 Answer 1

0

try:

cd ~/music
find . -type f | while read i; do album=${i/*\//}; temp=${i/.\//}; artiste=${temp/\/*\/*/}; song=${i/.\/*\/*\//}; mkdir ~/music/$artiste"-"$album; mv $i ~/music/$artiste"-"$album/$song; done 

though i would advise to use cp first instead of mv. just in case... this script does not remove the old folders as well.

basically it reads the full path name of each file. then extract the bits like artiste name, song title and album title. it then manipulates these information to give you the directory style you want.

3
  • Like the other script, it's hiccuping any time there are spaces in the directory name. Also, there isn't any artist/album info in the filename, just the title and track number. However, the parent folder is always the artist and each subdirectory under that folder is always the album titles.
    – Evan Davis
    Dec 28, 2010 at 2:31
  • Since we have already declared the album and artist as variables, if you want the album and artiste name in the filename you can change the $song output to something like $artiste"-"$album"-"$song. As for the space issue, perhaps you could do a quick
    – Reuben L.
    Dec 28, 2010 at 6:02
  • sed to replace all the spaces in filenames with underscores.
    – Reuben L.
    Dec 28, 2010 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .