Import mp3's on connecting an external drive

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Is this possible? I want to import songs into itunes as soon as I connect my external drive.
Right now I have a rule monitoring the Volumes folder, and growls as soon as it gets mounted. However now I want to import mp3's in my dropbox to get imported into my itunes library (which of course resides on my external drive).

Any ideas?

Thanks!
cyesergio
 
Posts: 4
Joined: Mon Jun 30, 2008 4:54 pm

(I moved this topic to the "Support" forum as it makes more sense there)

Are you importing from or to the external drive? If you don't mind a couple minute delay, Hazel should run the rules eventually and see that the drive is there. If you need to trigger it immediately, you may have to do something like "touch" the other folder (you are watching one folder but want to act on another). To do it would require a script.

If you could elaborate more, I think something can be worked out.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Yeah that's exactly what I want. I want to monitor one folder (the 'Volumes' folder) to see if my external is mounted. And as soon as it detects the drive, it imports music files in my dropbox (or any other local folder) to my itunes library, which resides one the external drive.
I guess I would need a script for that, as I need to do something to two different folders. However I have no experience in scripting, so any help would be appreciated!

Thanks in advance,

Cye
cyesergio
 
Posts: 4
Joined: Mon Jun 30, 2008 4:54 pm

Again, if you don't absolutely need Hazel to react immediately after mount, Hazel should import the files.

If you want to do the trigger, you can try using a shell script like the following:
Code: Select all
#!/bin/sh

touch folder-to-trigger


Replace folder-to-trigger with the actual folder you want Hazel to trigger. What the touch command is doing is setting the modified time on the folder which Hazel will see and wake up.

You need to save the above script to a file and set it to be executable. Or, if you are running the 2.2 beta, you can just enter it directly into Hazel's script editor.

Let me know how it works out for you.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Ok, this is getting interesting :) I donwloaded the beta 2.2 and pasted the code in with my with the actual folder name that needs to get 'touched'. However, what kind of rule should I apply to the 'touched' folder? There's a date modified condition; but how should I set it? I want it to import the files to itunes on touch.

Thank you for your fast replies!

-Cye
cyesergio
 
Posts: 4
Joined: Mon Jun 30, 2008 4:54 pm

The point of touching the directory is to make Hazel wake up and process it. The rules you set should be the same as before. The point of the touch script is to affect when Hazel runs the rules. The rule logic is up to you but you should get that part working first before trying to mess with forcing things to trigger.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Ok I think I might be a bit slow. The rules on the touched folder should ONLY be run when the external drive is connected. Now the rules get run whenever I drop a file in that folder...

This is what should happen:

Plug in ext. drive --> Hazel notices new folder(external drive) in /Volumes --> Hazel 'touches' a folder ---> the touched folder runs the rules (e.g. move files to external drive and import song into itunes).


Maybe I'm missing something but now the rules are being run whenever a file enter or leaves the folder (modified date gets set)

thanks for your help though I've come along way...
cyesergio
 
Posts: 4
Joined: Mon Jun 30, 2008 4:54 pm

The rules run whenever files are added or deleted but also periodically. If you attach a drive, Hazel will eventually run the rule successfully. If it fails, it will just try again later. Is there some reason why this is unacceptable? The suggestion to touch the folder was to trigger it sooner. It doesn't do anything that wouldn't have been done if you wait a couple minutes.

Maybe if you could clarify how things are not working now, that might help. Right now, I'm unsure of what the actual problem is.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron