Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Import music from command line

Hi all,

I would like to write a script which imports a mass of MP3 files into my iTunes. Basically it should "execute" the MP3 file, which means trigger the same reaction as double-clicking the file in the finder would.

Does anybody know how to do this? And yes, this is EXACTLY what I need - a method to control the input order of several mp3 files.

thanks in advance
Axel.

MacBook Pro 17", Mac OS X (10.6.4), iTunes 10

Posted on Oct 8, 2010 3:40 PM

Reply
1 reply

Jun 28, 2011 7:31 AM in response to Cazaril

At the command line.

It should be as simple as:

open "[path and filename of music file to import]"

ex: open "./Jazz/Benson & Klugh/Collaboration/02 - Mimosa.mp3"


I just ran a process of merging various copies of my music from 3 different stores.

I ran:

find . -type f -exec openssl -r sha1 > reponame_sha1.list

in each of the roots of the repositories.

pulled the sha1 hash out with a cut -c1-40 into another file.

ran a sort and uniq against those files

ran a diff [orig] [other]

did a grep "^>" to get uniq signatures from the other library

edited the file down to just the sha1 hash

did a bash loop through the sha1 list and grepped it agains the original [other] (before the cut -c1-40) and piped the output to a file.

edited this file (with vim) and:

:%!cut -c1-43

:%s/^/open "/

:%S/$/"/

:wq


The resulting filename looked like:

open "./Jazz/Benson & Klugh/Collaboration/02 - Mimosa.mp3"

open "./Easy - Classics/Frank Sinatra/Frank Sinatra - The Collection - 2 of 3/12 - You Make Me Feel (So Young).mp3"

open "./Christian Artists/America's Favorite Patriotic Songs/10 - God Save America.mp3"

open "./Classical/Johann Sebastian Bach/Bach for Barbecue/07 - Allegro from Brandenburg Concerto No. 4.mp3"

open "./Country/Martina McBride/Greatest Hits/02 - Life #9.mp3"

etc...


Then just ran the file with

. [filename]

Don't forget to be in the right directory for the above folder & file names.


It went through all the files and opened them one at a time in iTunes and that forced a copy.


So, the end result was a batch of files spread all over a folder structure.

I ran it for about 500 without any problem at all.

This took less than 3 min to run.

Import music from command line

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.