Page 1 of 1

Only import into iTunes when when iTunes is running

PostPosted: Sun Jul 28, 2013 1:53 pm
by adamchrist
Hello,

I'm currently in my trial period for Hazel and loving it.
There is only one problem or action I'm looking for, so far I haven't figured it out.

I want to have a watched folder where audio files automatically get imported into iTunes.
The only problem is my iTunes library resides on an external HDD which isn't always connected.

Is it possible to have the "import into iTunes" line run only when the external HDD is connected or iTunes is actually open? (I prefer the last one).

I hope someone can help me with this.

Cheers
David

Re: Only import into iTunes when when iTunes is running

PostPosted: Sun Jul 28, 2013 2:31 pm
by adamchrist
I think I actually cracked the problem :shock:

Using an Applescript

Code: Select all
on hazelProcessFile(theFile)
   
   if application "iTunes" is running then
      tell application "iTunes"
         launch
         try
            
            add theFile
            
            set the file_path to the quoted form of the POSIX path of theFile
            do shell script ("rm -f " & file_path)
            
         end try
      end tell
   end if
   
end hazelProcessFile


I'm not an experienced scripter at all, so if the above can be more efficient please tell me.
Also if it can be made so it imports into a specific playlist, please do share :mrgreen:

Well for now this seems to be doing the trick

Re: Only import into iTunes when when iTunes is running

PostPosted: Sun Jul 28, 2013 3:17 pm
by sjk
An alternative might be to make use of the "Automatically Add to iTunes" folder.

Re: Only import into iTunes when when iTunes is running

PostPosted: Sun Jul 28, 2013 3:23 pm
by adamchrist
Ah great, way simpler, thanks sjk!