Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add folders to the iTunes library via the command line Apps
If, like me, you like to make yourself feel all l33t by doing a lot of system and file management on the command line, you'll have been frustrated at least once by failing to be able to add freshly-downloaded MP3s to the iTunes library (once you've salted them away in your carefully-ordered music stash, naturally) via Terminal.

Well, be frustrated no more! Here is a handy-dandy AppleScript I wrote to do just that right in the shell. It takes the path to your newly-minted MP3 folder as an argument, and here's the code:
on run named_folder
  set folder_alias to POSIX file named_folder
  tell application "iTunes"
    add folder_alias to library playlist 1
  end tell
end run
On Leopard, save this to a text file with this as the first line:
#!/usr/bin/osascript
Then chmod a+x the script to make it executable, and you can invoke this as you would any shell script:
~/scripts/addToITunesLibrary ~/Music/mp3/_purchased/Malcolm Middleton/
On pre-Leopard systems, you'll need to save it out as a regular AppleScript via Script Editor, and invoke using osascript, thusly:

osascript ~/scripts/addToITunesLibrary.scpt ~/Music/mp3/_purchased/Malcolm Middleton/

[robg adds: I haven't tested this one.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[12,606 views]  

Add folders to the iTunes library via the command line | 5 comments | Create New Account
Click here to return to the 'Add folders to the iTunes library via the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add folders to the iTunes library via the command line
Authored by: sjk on Sep 04, '08 01:12:47PM
Alternatively:

open -a iTunes files

[ Reply to This | # ]
Add folders to the iTunes library via the command line
Authored by: prehensile on Sep 05, '08 04:25:50AM

Man, I wish I'd known about that in the first place. ;)



[ Reply to This | # ]
Add folders to the iTunes library via the command line
Authored by: blubalu on Sep 06, '08 01:17:00PM

is there also a command for adding art work to a playlist?



[ Reply to This | # ]
Add folders to the iTunes library via the command line
Authored by: sheepworrier on Nov 29, '10 05:34:55AM

Thanks for the tip. However, I found that when using this, iTunes would always start playing the first file that I was importing. This wasn't particularly welcome when other people in the house were sleeping :-)

So, I found an alternative. From iTunes9, there is a folder under the "iTunes Library" called "Automatically Add to iTunes". Simply copying / moving files to that folder causes them to be imported into the iTunes Library next time iTunes is opened.



[ Reply to This | # ]
Add folders to the iTunes library via the command line
Authored by: andreasordell on Nov 02, '08 05:17:16AM

Awesome, thanks!

Have one question though, when adding a folder that contains other files (for example a nfo file) I get an error. Is there any way to include only the audio files of the folder?



[ Reply to This | # ]