You are not logged in.

#1 2010-12-21 10:46:21

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Idiot messes up his music collection with Picard (help fix)

I managed to get all my music into a whole mess using Picard (music brainz) without really monitoring what it was doing.

I've ended up with music in folder paths such as /album/name/artist/name/artist/name/artist/name/artist/name/artist/name/artist/name/artist/songs

The exact wording of the path is not regular except for the repetition.

I need to somehow call a script that would look for repetition in path names, copy all the files to the top level and then remove the sub/sub/sub directories.

Not sure where to start....

Offline

#2 2010-12-21 10:51:10

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Idiot messes up his music collection with Picard (help fix)

... or you could just copy/move all the music files to another dir somewhere and use picard or another tagger in a sensible way to create a sane sub-dir structure.

Offline

#3 2010-12-21 10:56:14

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Idiot messes up his music collection with Picard (help fix)

a similar situation exists where I must go down all these paths to the music and move them out.

Still a hint on how to grab all the .mp3 .ogg .flac and so on out of this maze and move it elsewhere would help me greatly smile

Offline

#4 2010-12-21 11:03:08

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Idiot messes up his music collection with Picard (help fix)

think i fixed it with wildcards mv /musiclocation/*/* whatever

Offline

#5 2010-12-21 11:22:48

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Idiot messes up his music collection with Picard (help fix)

I'll give you the hint anyway:

man find

smile

Offline

#6 2010-12-21 12:17:07

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Idiot messes up his music collection with Picard (help fix)

......of course what I wanted was a nice line with

for this and that do this and that bla bla 

resulting in the files all being moved, checks for any wierdness and then removal of the redundant dir structure.

What I had to do was a set of manual /*/* kind of mv commands until I thought I had all the music in one location.

Oh well. All done now

thanks for the tip on the find command. !(

Offline

#7 2010-12-22 05:38:23

rockin turtle
Member
From: Montana, USA
Registered: 2009-10-22
Posts: 227

Re: Idiot messes up his music collection with Picard (help fix)

I realize I'm late to the party, but you could have moved all your music files from your faulty directory structure to a new directory using the following bash script.

#!/bin/bash

shopt -s globstar
for f in **/*.{mp3,ogg,flac}
do
    dest="${f%%/*}"
    [[ -d "$dest" && -w "$dest" ]] && mv "$f" "$dest"
done

The 'shopt -s globstar' sets the "globstar" shell option.  This causes the '**' in the next line to match 0 or more directories and subdirectories.

The way this script works is as follows.  The script would loop, setting 'f' to the name of each music file in succession.  Assume that for some iteration of the loop, f gets set to:

    f -> "album1/name/artist/.../name/artist/song1.mp3"

then dest would get set to:

    dest -> "album1"

and finally the command

    mv "album1/name/artist/.../name/artist/song1.mp3" "album1"

would be executed.  You would have to manually delete your empty subdirectories.

If you wanted to preserve the 'album/name/artist/' directory structure and simply remove the redundant 'name/artist/...' subdirectories, that could be done, but it would probably require a script that is much more complicated.

Offline

#8 2010-12-22 07:01:59

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Idiot messes up his music collection with Picard (help fix)

smart. Thanks @rockin, that is a very interesting script and I learned from it.

Offline

Board footer

Powered by FluxBB