I admit that my music collection is a royal mess. This is the result of merging many sources of music (external drive, old iPod sync, iTunes purchases, etc) into my iTunes account. iTunes Match has done a pretty good job of cleaning it up visually as I look at it in iTunes.

What I want to do is create a backup copy of all my music no matter where it lives (external HD, etc.) to one location and hopefully eliminate duplicates in the process.

More specifically, I setup a smart folder to find all of kind:music with a bitrate over 44kbps. This results in over 20,000 music files at around 485 GB. I now want to copy all this content to my external drive to ensure I have a backup of all these audio files.

I tried a simple select all and drag to copy, but that didn't seem to work. After a few days of Finder "not responding", I killed the process. Some zero-byte files were created on the external drive, but no sign of progress after the first few minutes.

I'm wondering if there is a Terminal command that could reference the contents of a smart folder and copy or some other creative way to get this done.

I really don't want to mess with iTunes, I just want to copy all music files to the external HD. Bash script maybe?

  • Copying over 485 GB would definitely take a long time, probably 3 days at normal iMac write speeds. It would be good to divide the files into groups of about 10 GB, and work with them. – duci9y Aug 31 '12 at 18:17

You could use mdfind in a shell script to simulate your smart folder's settings (mdfind is how you use Spotlight from the command line). Use kMDItemKind to specify the kind and kMDItemAudioBitRate for the bitrate.

Then you can use that list of files and copy them to your external drive.

Something like this script below. (scp copies files to a server; use cp to copy to a drive. Or, if you want to get fancy, rsync is generally better for incremental backups.)


for FILE in $(mdfind 'kMDItemAudioBitRate >= "44000"')
    scp $FILE myname@myserver:~/music-backup
| improve this answer | |
  • kMDItemKind didn't work, but after some digging, I found that kMDItemContentTypeTree = public.audio does work. This lists all audio file types, so may be too broad for some. – knipknup Sep 4 '12 at 15:10
  • @knipknup Yeah, I poked around with kMDItemKind and the only way I could get it to work properly was to make a Smart Folder in the Finder, choose "Kind = Music" and copy the number that it saves in the file. – Cajunluke Sep 4 '12 at 15:33

You must log in to answer this question.

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