Shell script to copy Music/Artists/Albums/Songs to Music2/Artists/Songs

Hi,
My Music folder is currently organized as follows (standard iTunes behaviour):
Music
Artists
Albums
Songs
Artist1
Album1
Song11
Song12
Song13
Album2
Song21
Song22
Artist2
Album1
Song11
Song12
Album2
Song21
Song22
Song23
etc.
I would like to copy this Music Folder to an USB flash drive, but without the "Albums" level, i.e.:
Music2
Artists
Songs
Artist1
Song11
Song12
Song13
Song21
Song22
Artist2
Song11
Song12
Song21
Song22
Song23
I assume that an unix shell script is able to do this, but this is beyond my skills
Or do you know a software that can manipulate files in such a way?
Thanks in advance.

OK, clear. For future runs, should I be better off runing the command in a directory on my Mac, and copy the resulting music folder to the USB drive?
No, the optimum solution would be to format the thumb drive with the HFS+ filesystem. You could use cp, ditto, or rsync will the proper options and not copy the file fork to the thumbdrive. Or you could  filter out the file forks in the two find commands.
ls | while read dir; do
    find "${dir}" -type f ! -name "._*" \( -name "*.mp3" -o -name "*.m4a" \) -print0 | xargs -0 -I '{}' mv -n "{}" "${dir}"
done
find . -type f ! -name "._*" \( -name "*.mp3" -o -name "*.m4a" \) -mindepth 3 | while read file; do
     base=${file%\/*}
     base=${base##*\/}
     mv "${file}" "${file%*\/*\/*}"/"$base"_"${file##*\/}"
done
The warning or error messages are innocuous anyways.
OK. I removed them manually, which took me less than one minute. Should I add a "rm -r .DS_Store" step before future runs?
I wouldn't bother. Change->
find . -type d -empty -delete
to
find . -type d -mindepth 2 -maxdepth 2 -exec rm -rf '{}' '+'

Similar Messages

  • Applescript/shells script for capture one

    Hey,
    Wanting a script that will take the last item copied to the clipboard (which will be a folder name), search for it in finder, in "this mac", and then open the folder in Capture One.  It would be great if it were ready to run, so I could launch it each time with a keystroke.  Any one willing to help me on this.  Thanks so much!!
    I know a little applescript, but this one is kind of out of my league, I think, at least.

    Hi,
    You can use this script in an Automator Service (you can assign a keystroke combination to this service).
    If the script find one folder whose name equal the contents of the clipboard, "Capture One" will open this folder.
    if the script finds multiple folders whose name equal the contents of the clipboard, it will do nothing, because I don't know what you want in this case.
    To create a service, you start by selecting New from Automator's File menu.
    You should select the Service option, which is accompanied by a gear icon, clic "Choose" button.
    In your new service, you will see a bar at the top of the Automator flow pane. It has combo boxes that allow you to set filters that establish the conditions in which your service should be made accessible. You want to make a service that receives selected "No Input" and will operate in any application or select an application.
    Add the "Run Shell Script" action
    Copy/paste this script in the action:
    folder=$(mdfind "kMDItemFSName = \"$(pbpaste -Prefer txt)\" && kMDItemContentType = \"public.folder\"")
    if [ -z $folder ];then exit 0;fi ## no match
    tot=$(wc -l <<< "$folder")
    if [ $tot -eq 1 ]; then open -b 'com.phaseone.captureone7' "$folder"; fi
    Replace the bundle identifier in this script --> 'com.phaseone.captureone7'
    To know the bundle identifier of your "Capture One" application, run this AppleScript, copy the result to change the  bundle identifier in the shell script
    tell application "Finder" to get id of (application "Capture One")
    Save the service, quit Automator
    The final step is to assign a keystroke combination to the newly created service.
    Open the System Preferences application and navigate to the Keyboard preference pane, and select the Shortcuts tab.
    From the list on the left of the preference pane, select the Services category.
    A list of the installed services will be displayed to the right.
    Scroll to the last category titled General, and locate the service you just created.
    Double-click to the far right of the service name to activate the keystroke input field and then type the key combination you wish to assign to the service.
    Close the System Preferences application.

  • File locking and shell script

    Hi,
    with Mac OS X is there a file locking system to prevent file to be copyied or move to a folder B before they are completely copyied in folder A ?
    Regards

    The files in folder A are created by a program like
    Pitstop
    My question was : what can happen if a file in folder
    A is not complitely created and the shell script
    attempt to copy it ?
    In general, if the shell script attempts to copy a file before the creator is finished writing to it, the shell script will copy the part of the file that's already present, so the copy will be incomplete. The creating application can prevent that (by writing to a temporary file and changing the name of the file only after it's finished writing, or by making the file readable only after it's done), but that's up to the application.

  • Using an external shell script rather than a main class

    I've just started to use Creator and I'm like to replace the "Run" function with a call to a shell script. The projects are all libraries (no main class) so the shell script will copy the jar to a another location and perform some other tasks such as starting/stopping services.
    I've tried uncommenting the target tag example in the build.xml file but that had no effect.
    Any ideas?

    I've just started to use Creator and I'm like to replace the "Run" function with a call to a shell script. The projects are all libraries (no main class) so the shell script will copy the jar to a another location and perform some other tasks such as starting/stopping services.
    I've tried uncommenting the target tag example in the build.xml file but that had no effect.
    Any ideas?

  • Copying artist/album/songs titles into word document

    i am wanting to to copy the artist, albums and song titles into word so i can print it out and store a hard copy with my back-up dvd that i did?
    is it possible?
    many thanks if anyone can help

    I'm not sure how you can get this information into Word, but you can print a list with the following columns: song/length/artist/album for your entire library in iTunes. To do this, make sure you're in your main library and that you have your music listed in the order you want the final document to appear. Then on the top line select File>Print> then put a check mark in the song listing circle and hit okay. You should get a printed list of everything in your library.

  • Under music my artists tab disappeared but still have albums, songs etc how to get artists tab back?

    Under music the artists tab disappeared but still have albums, songs etc. 
    how to  get artists tab back?

    Hi Gary gar,
    Welcome to the Apple Support Communities!
    It sounds like the options at the bottom of the Music application may have been edited. You can click the More section on the far right, then choose Edit in the top right. You can then drag any options you want to that bottom bar and rearrange them.
    Browse and play - iPhone
    http://help.apple.com/iphone/7/#/iph3cf21a82
    Tired of tapping More? To rearrange the buttons, tap More, then tap Edit and drag a button onto the one you want to replace.
    Have a great day,
    Joe

  • I'm having troube with music. Some artists that start with an "P" appear under the "R" menu and similarly throughout the alphabet. Same about albums, songs

    I'm having troube with music. Some artists that start with an "A" appear under the "B" menu and similarly throughout the alphabet. Same about albums, songs and genres. It suddenly happened after about 3 days of iOS 5 usage. Re-synchronization doesn't help. I also tried deleting some artists from ipod, but it doesn't help either.

    1) This is because of software version 1.1. See this
    thread for some options as to how to go back to 1.0,
    which will correct the problem...
    http://discussions.apple.com/thread.jspa?threadID=3754
    59&tstart=0
    2) This tends to happen after videos. Give the iPod a
    minute or two to readjust. It should now be more
    accurate.
    3) This?
    iPod shows a folder icon with exclamation
    point
    4) Restore the iPod
    5) Try these...
    iPod Only Shows An Apple Logo and Will Not Start
    Up
    iPod Only Shows An Apple Logo
    I think 3,4, and 5 are related. Try the options I
    posted for each one.
    btabz
    I just noticed that one of the restore methods you posted was to put it into Disk Mode First rather than just use the resstore straight off, I Have tried that and seems to have solved the problem, If it has thank you. previously I have only tried just restoring it skipping this extra step. Hope my iPod stays healthy, if it doesnt its a warrenty job me thinks any way thanks again

  • When I copy an artist over to itunes and that particular album has multiple albums, it does not separate the albums but lines up all of the songs...such as all the 1's..then 2's and so on.  How do I fix that?s

    when I copy an artist over to itunes and that particular album has multiple albums, it does not separate the albums but lines up all of the songs...such as all the 1's..then 2's and so on.  How do I fix that?

    JPSchrader wrote:
    when I copy an artist over to itunes and that particular album has multiple albums...
    Should that read "when I copy an artist over to itunes and that particular artist has multiple albums," because if not, I don't understand?
    If I'm right about that, I'm still not really clear at all about what you're doing. Where are you importing these songs and albums from? Is it existing songs files and if so, what format are they in?

  • Sort Music-- Artist-- Albums-- All Songs where all songs are alpha order

    I have quite a lot of songs on my iPod classic. For example I have 253 Beatles songs alone. When I go to Music-->artist-->songs they are all organized by Album. When I'm driving or even just sitting still this method of organization is just extremely inconvenient. I feel like it can't be that difficult to make it sort "all songs" by alphabetical order. Let me know if it is and if I'm just missing it...

    The layout cannot be customised.
    tt2

  • ITunes won't copy music files to Media folder when songs are dragged

    I am trying add songs from my external hard drive to my iTunes Library.
    I have the following options checked:
    "Keep iTunes Media folder organized."
    "Copy files to iTunes Media folder when adding to library."
    In the past, I could just drag files from my hard drive into the iTunes song list and add them to the library. iTunes would successfully make a copy of the file to the iTunes Media folder so that I could disconnect the hard drive and still play the songs.
    Suddenly, this no longer works. iTunes won't make a copy of the file anymore. It won't even make a copy of files located on my desktop.
    I found a workaround -- copy the files from my hard drive to the desktop. Then I have to go to File > Add to Library in order for it to work.
    It's an extra step, but it was VERY annoying to have to figure out.
    So my question -- Is this an iTunes bug or some kind of deliberate attempt at making it hard to use files not purchased through iTunes?
    I noticed this on one of the Apple support pages (my emphasis):
    Copying music to and keeping the iTunes Media folder organized
    You can select these options on the Advanced pane of iTunes preferences:
    "Keep iTunes Media folder organized." Learn more about how iTunes 9 and later organizes your media.
    "Copy files to iTunes Media folder when adding to library." Select this option to store all your media files in the iTunes Media folder. Since it's all in one location, you can easily transfer or back up your media. When you purchase or import media into iTunes from a CD, it's automatically added to your iTunes Media folder. If you add media to iTunes another way (choosing "Add to library" from the File menu or by dragging an MP3 file into iTunes), it might not be added to your iTunes Media folder.
    Well, why the heck not??

    I have posted so many issues to APPLE on the staggering lack of  basic functionality with itunes and each time they keep deleting it.
    Automatically Addd feature does not work consistently if the library is on NAS or a drive not on the same bok as the Mac, iMac or PC.
    iTuns will hang if you have the finder window open  and the recently added playlist open
    itunes will not add files automatically  if more than three phases of adding folders to the automatically add to itune folder is refreshed
    Once could even jump to the conclusion that the software testing and Quality Control in the iTunes development team had missed out whole chunks of tsting OR that the test designers wrote such basic test scripts which did not replicate real world useage.

  • Screen Goes Black and Hangs when browsing by Artist, Album, Song, etc.

    I'm having a fairly huge issue with Front Row:
    I can play video files (although their is a moment of hangtime between selecting a video and the video actually playing) and music files (if I choose the "Shuffle Songs" option), however, when I choose to browse my music by artists, albums, songs, genres, etc. my screen goes black and stays that way until I hit CMD+Q over and over until it finally quits. Furthermore, when I do play music via "Shuffle Songs" and quit out of Front Row, the music continues to play in the background and cannot be stopped, paused, etc.
    Is there anyone out there who can help me fix this? I love Front Row and use it all the time and it would be a shame not to be able to anymore..
    Thanks in advance,
    Corey

    I have a similar problem. When browsing music the screen goes to black or just freezes on whatever was beeing displayed for maybe 30 seconds to a minute before continuing. It happens quite often. I am running the latest version of Front Row on a brand new Mac Mini. I have a very large iTunes music folder (about 830 gigabytes of uncompressed AIFF files) running on an external FW800 drive. I tried repairing permissions and a number of Front Row and a few iTunes files appear in the list. However, when I run repair permissions again, the same files are still listed so obviously if they need to be repaired, it's not happening. I tried repairing the volume (no problems found) and repairing permissions from the Install disc but the result was identical.

  • Alphabetical sorting of Music Artists [Name of Artist] All Songs?

    When I go to Music>Artists>[Name of Artist]>All Songs, it sorts the songs by album, is there a way to have this sorted alphabetically instead, without regard to album? Basically I want a way to view an alphabetical list of songs by a certain artist without making a million playlists. This would only apply to Music>Artists>[Artist]>All Songs, I want everything else to stay as is. This is for a current gen Ipod Classic. Also, would doing this (if it's even possible) mess up the sorting of artists who I only have one album for (I would want these to stay sorted by track number)?

    Regarding the playlists, just click on the NAME column within each playlist to sort the list by name. Make sure the shuffle icon is not selected before you do this. Your playlists will be in Track Name order now. (You must do this for EACH playlist)
    I believe when choosing an individual artist, then choosing all albums by that artist, the tracks will be sorted by album name then track number per album, so the ALBUMS will be played in alphabetical order, but the songs will play in the track order of each album. There is no way to chage this, as far as I know.
    There may be a workaround for this by removing all the track numbers from all of your files. However, this will mess up your album order if you ever wish to listen to individual albums.
    To each his own, I know, but hearing all songs in alphabetical order drives me insane.

  • ITunes music view: Albums by Artist/Year. Still not what I want it.

    Ok, what I'm looking for from iTunes is for it to organize my music by album. Put all the albums together regardless of the artist. Then I want it to lump albums by a single artist together. Then organize that by year. Is that possible? Currently when I use the Album by artist/year, the albums with multiple artists aren't together. They're all over the place according to the artists name. I want my coverflow view to look like I'm going through a jukebox. Jukebox view. How's that for a setting, Apple?

    f it happens every time you get a new computer, one would think you would have figured it out by now...
    Media sync is one way. Computer -> Phone. Copy the media from your old computer to the new computer. Then let iTunes wipe it off of your phone and re-sync.
    The only media you can transfer from the phone to the computer is media purchased on the phone from the iTunes store. Use File>Transfer Purchases in iTunes to do that.

  • How do I get songs from certain artists to appear under the "Music → Artist

    How do I get songs from certain artists to appear under the “Music → Artists” menu of my iPod if some of the artists songs have album information and some don’t?
    For example, I might have a full album from an artist, and then a single track from the same artist, but without an album tag. When I go to “Music → Artist”, the single track without album information will be gone. The only way I can find the single track is if I go to “Music → Songs” and find it in there.
    I have thousands of MP3s, and finding songs by artist is my preference. Is there any way I can get all tracks to appear under the Artists menu without having to add album information to every single track?

    From what I understand (thanks to forum member PT for this), once you add a second album name for that artist even for a single song, ALL the rest of the songs should now show up under that artist, even those without album names.
    Providing the spelling for the artists is exactly the same of course.

  • Music artist/album not working

    I have had this problem i cant seem to figure out since updating to ios 8. The problem seems only when 2 artist have the same album name. Example i have Outkast "Greatest Hits" and 2pac "Greatest Hits".
    If i go to music > Artist > 2Pac > all the songs are fine
    but,
    If i go to music . Artist > OutKast > it shows the 2pac greatest hits
    It does this with multiple artist, it shows someone else's music if they have the same album name.
    I have made sure all the correct tags are entered into itunes and the album artist/artist are correct, also tried with album grouping on and off on my iphone 5s.
    I cannot figure out what is causing the issue, but it worked great in ios 7 and with my past iphones.
    Any help would be greatly appreciated.
    Thanks

    The key to using the Album Artist field is that it only works right if each song is also marked as belonging to a compilation. This choice has been moved to the Options tab in iTunes 8. +Album Artist+ should really by renamed +Compilation Artist+ to make its purpose clear.
    Do four things for every track on a compilation album:
    1. Fill in Album Artist exactly the same on every song, using an umbrella term like "Various Artists" or "Original Broadway Cast."
    2. Make sure all songs have the same album title.
    3. Make sure all songs have accurate "Disk __ of __" entries. If all songs are from one disk, it's easiest to erase the disk numbers. Alternately, you could put "1 of 1" in those boxes. Just don't have one song say "1 of 2" while another is blank.
    4. For all songs, select Yes from the Compilation menu on the Options tab.

Maybe you are looking for

  • DVI to ADC adapter STudio display will not power on when used with Mac mini

    I have a Mac mini and I just purchased a used apple 17" CRT studio display. I bought the DVI to ADC Adapter as recommended by my Apple store. When I hook everything up (I have checked and redone this two times) The power light will come on for about

  • SCCM Client Report Tool not opening up correct URL to Report Server

    I recently install the SCCM 2012 right click tools and within the downloaded zip file there is SCCMClientToolsSetup2012.exe which adds a whole bunch of additional features when right clicking devices in the console. The problem is no matter what I pu

  • A question about transport orders simultaneous

    Hi, we are having a problem in a long time ago. Sometimes when two users import a order each, the transport system hangs (we solve this hang deleting orders and killing tp processes). We need to know: 1.- Why this occurs some times (and not in all ti

  • Map Builder - Bulk import

    Hi, I have several thousand tiff images (orthophoto maps) and I am using Map Builder for importing, making georaster theme and adding themes into base map. It will last for ages... Is there other way how to do it? thanks, Branislav

  • Css transitions in safari

    I  recently added some CSS transistions to my pages that work correctly on I.E., Chrome, Firefox, but tried to open my site on an Apple I-Pad running Safari and they just sit there.    Do I need to alter my code in some way so Safari can handle them