How can I add a file to iTunes, from the command line, without playing the file

I want to add a file to iTunes from the command line. I can't use the Automatically Add to iTunes folder, because then iTunes will rename the file, and I don't want that. I can simply type iTunes filename. That does add the file to the library, but iTunes also plays the file, which is no good either.

So, how can I add the file, so that it doesn't get renamed and doesn't get played?


Solution 1:

On a Mac you could use AppleScript to add the file to iTunes:

osascript -e "tell application \"iTunes\" to add Posix file \"/Users/james/myMov/myMov.m4v\""

This works the same as importing using the GUI, so if iTunes is set to organise your media files then the file will be moved, otherwise the file will remain in it's current location. I believe that you need the absolute path to the file (personally I'd use Bash to find this).