Capture song files into artists folders
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Capture song files into artists folders

    Some coding help please --

    I have a folder of individual songs ... is there an easy coded way to scan the directory, and save all the files of an artist into a folder named for that artist ? (Doris Day, Duke Ellington etc..)

    Here is an example of what the folder looks like:

    Click image for larger version. 

Name:	Selection_006.png 
Views:	28 
Size:	124.5 KB 
ID:	30427
    ***********************
    * Bill Clark Windham, VT *
    ***********************

  2. #2
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    6,799
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    You could try something like this:
    Code:
    #!/bin/bash
    for x in *mp3; do echo "${x% - *.mp3}"; done | sort | uniq | while read -r fldr; do
       if [ ! -d "$fldr" ]; then
          eval mkdir \'$fldr\'
       fi
       eval mv \'${fldr} - \'*mp3 \'$fldr\'
    done
    Save and run that script in the directory that contains the mp3 files.
    OS: Fedora 29 x86_64 | Machine: Lenovo ThinkCentre M91P | CPU: Intel Core i5-2500 3.30GHz | RAM: 8GB PC3-12800 DDR3 | Disk: 500GB SATA | Video: Intel HD Graphics 2000 128MB | Sound: Realtek ALC662 | Ethernet: Intel 82579LM

  3. #3
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    1,053
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Rather than do it manually/scripted, if you use something like MusicBrainz Picard it will scan each music file to determine what the song is and ensure the tags are all correct, and rename the files to whatever you want, for example ./<artist>/<artist> - <song>.mp3.

  4. #4
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Wow - -- just wow.

    Going to try this when I get back from work tonight...THX!
    ***********************
    * Bill Clark Windham, VT *
    ***********************

  5. #5
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Quote Originally Posted by RupertPupkin
    You could try something like this:
    Code:
    #!/bin/bash
    for x in *mp3; do echo "${x% - *.mp3}"; done | sort | uniq | while read -r fldr; do
       if [ ! -d "$fldr" ]; then
          eval mkdir \'$fldr\'
       fi
       eval mv \'${fldr} - \'*mp3 \'$fldr\'
    done
    Save and run that script in the directory that contains the mp3 files.
    I created script in same directory as songs ..

    IT WORKED!! script named cleanmp3.sh --Every song is now in a folder with the artist name ! There were a few small errors, but no biggie I think the punctuation may have thrown off the mv command (like Howlin' Wolf etc..) ... thx for the great code ! !!

    Here is what I errors I got:
    [root@vorty2018 Cedar Creek Radio]# ./cleanmp3.sh
    mkdir: cannot create directory ‘’: No such file or directory
    mv: target ‘’ is not a directory
    ./cleanmp3.sh: eval: line 4: unexpected EOF while looking for matching `''
    ./cleanmp3.sh: eval: line 5: syntax error: unexpected end of file
    mv: target ‘Blacks Combo’ is not a directory
    ./cleanmp3.sh: eval: line 4: unexpected EOF while looking for matching `''
    ./cleanmp3.sh: eval: line 5: syntax error: unexpected end of file
    mv: target ‘*mp3 Hermans Hermits’ is not a directory
    ./cleanmp3.sh: eval: line 4: unexpected EOF while looking for matching `''
    ./cleanmp3.sh: eval: line 5: syntax error: unexpected end of file
    mv: target ‘*mp3 Howlin Wolf’ is not a directory
    ./cleanmp3.sh: eval: line 4: unexpected EOF while looking for matching `''
    ./cleanmp3.sh: eval: line 5: syntax error: unexpected end of file
    mv: target ‘Murads Harmonicats’ is not a directory
    ./cleanmp3.sh: eval: line 4: unexpected EOF while looking for matching `''
    ./cleanmp3.sh: eval: line 5: syntax error: unexpected end of file
    ***********************
    * Bill Clark Windham, VT *
    ***********************

  6. #6
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Thanks again for the wonderful code ..

    I have found a set of music files with slightly different naming format. Instead of artist - songtitle.mp3 it is artist - songtitle - album.mp3 ..
    running your original code against this new naming format will create folders names with the entire filename, and then put the file inside it.

    For example: "Frank Sinatra - The Girl From Ipanema - Album The Complete Reprise Recordings". Is there any way to slightly modify the code so it ignores the third field ? If it helps, every song has the third field starting with word "Album". ... thank you in advance..
    ***********************
    * Bill Clark Windham, VT *
    ***********************

  7. #7
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    6,799
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Quote Originally Posted by kappclark
    I have found a set of music files with slightly different naming format. Instead of artist - songtitle.mp3 it is artist - songtitle - album.mp3 ..
    running your original code against this new naming format will create folders names with the entire filename, and then put the file inside it.
    Try this:
    Code:
    for x in *mp3; do echo "${x%% - *}"; done | sort | uniq | while read -r fldr; do
       if [ ! -d "$fldr" ]; then
          eval mkdir \'$fldr\'
       fi
       eval mv \'${fldr} - \'*mp3 \'$fldr\'
    done
    OS: Fedora 29 x86_64 | Machine: Lenovo ThinkCentre M91P | CPU: Intel Core i5-2500 3.30GHz | RAM: 8GB PC3-12800 DDR3 | Disk: 500GB SATA | Video: Intel HD Graphics 2000 128MB | Sound: Realtek ALC662 | Ethernet: Intel 82579LM

  8. #8
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    !! It worked RupertPupkin ... this totally will make my weekend digital housecleaning go so much better -

    Sincere thanks for the elegant edit..
    ***********************
    * Bill Clark Windham, VT *
    ***********************

  9. #9
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    1,053
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    On a related song housecleaning note, do you ever play your songs on shuffle and find a song from one album is much louder or quieter than the next? If so then mp3gain can equalize all the volumes.

  10. #10
    Join Date
    Mar 2018
    Location
    Vermont, USA
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Capture song files into artists folders

    Yes I have, esp when I make cd's for friends...I know I can level the playback in the burning swI (keb) - hate to muddle with gain riding and compress an already compressed music file ... but in the car it can be a real surprise...I will check out mp3gain..thx
    ***********************
    * Bill Clark Windham, VT *
    ***********************

Similar Threads

  1. Files & Folders
    By parpi in forum Using Fedora
    Replies: 21
    Last Post: 13th September 2011, 10:13 AM
  2. playback dsp capture files
    By tkalfaoglu in forum Using Fedora
    Replies: 0
    Last Post: 12th April 2010, 08:36 AM
  3. How to maintain files and folders for changes
    By duni in forum Using Fedora
    Replies: 0
    Last Post: 27th April 2007, 10:53 AM
  4. For all Artists
    By weapon-x in forum Using Fedora
    Replies: 0
    Last Post: 29th October 2006, 11:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •