Announcement

Collapse
No announcement yet.

Moving/Renaming Music Files

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Moving/Renaming Music Files

    Hi, I'm new to Kubuntu, I copied over my music collection in iTunes to an external hard drive and after installing Kubuntu I moved the iTunes collection into a folder named Music under /home. Problem is iTunes sorts the music by directory "My Documents/My Music/iTunes/Artist/Album/song files" and now under Kubuntu its "/home/Music/Artist/Album/song files" and I would now like to make it "/home/Music/song files".

    I'm sure there's a pretty simple terminal commend to do this, there's just one problem, I have songs with the same name under different albums, so I would need to attach the Artist's name and Album to the beginning of the music file names.

    I have just under 200 GB's in music so if someone could help me out here, that would be great.

    Thank you,
    Austin

    P.S. I'm using Kubuntu 7.10, 64 bit if that matters at all.

    #2
    Re: Moving/Renaming Music Files

    you'll need to place the following shell script:
    Code:
    #!/bin/bash
    
    exec > /tmp/renaming.out 2> /dev/null
    
    START_DIR=/home/Music
    
    cd $START_DIR
    
    # loop on the artists
    #
    ls | while read artist
    do
     echo "the current artist is...${artist}"
    
     # loop on the current artist albums
     #
     cd "$artist"
     ls | while read album
     do
      echo "  the current album name is....${album}"
      echo "  the new album name will be...${artist}_-_${album}"
    
      # loop on the current album songs
      #
      cd "$album"
      ls | while read song
      do
       echo "    the current song name is....${song}"
       echo "    the new song name will be...${artist}_-_${album}_-_${song}"
       #mv "${song}" "${artist}_-_${album}_-_${song}"
      done
    
      # go up one level
      cd ..
     done
    
     # go up one level
     cd ..
    done
    in a file in your home directory, give it a name and do the following:
    chmod 750 <filename>
    ./<filename>
    now...
    this script doesn't do anything...yet!
    the actual rename (mv) command is commented out.

    what this script does now is pretend to do the work.
    and it will place an output file called renaming.out in /tmp.
    so that you can check that your song files will be renamed correctly.

    you can then run the script with the actual rename command
    once you've inspected the output file a you're reasonably sure
    nothing will be messed up...

    hth
    gnu/linux is not windoze

    Comment


      #3
      Re: Moving/Renaming Music Files

      oh...
      and do a backup before you do anything!
      gnu/linux is not windoze

      Comment


        #4
        Re: Moving/Renaming Music Files

        Thank you so much!!!

        I still have everything on the external hard drive so no harm done if it screws something up.

        Austin


        Edit:
        It seems to almost work. There is one problem though, it's running in every directory that's in /home.

        Comment


          #5
          Re: Moving/Renaming Music Files

          mmm...
          it shouldn't.
          it should start in /home/Music (got it from your original post) and work recursively from there.
          cfr:
          Code:
          START_DIR=/home/Music
          cd $START_DIR
          .
          if this isn't correct, then just replace the value of START_DIR with the actual one in the script.
          save it and run it again.

          or there could be some symbolic link in the music directories hierarchy that makes the script jump out.
          it doesn't make much sense, but you never know...

          check the above first.
          we can then look into this second option later.
          gnu/linux is not windoze

          Comment

          Working...
          X