Make Hazel move parent folder

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

Moderator: Mr_Noodle

Make Hazel move parent folder Wed Jul 14, 2010 5:44 pm • by missdigital
Hi!

I would like to create a rule to move a folder based on the contents of this folder. What I have so far, is this:

If Kind is Folder
Run rules on folder contents

Then a new rule

If name contains <some_characters>

Do the following:
move the parent/containing folder to a new location.

Is there a way to do this without using AppleScript?
As in Subfolder Depth is -1 or something?

I'm new to Hazel, so sorry if I'm asking something that is really obvious.
Thanks for helping!
missdigital
 
Posts: 3
Joined: Wed Jul 14, 2010 5:38 pm

Re: Make Hazel move parent folder Thu Jul 15, 2010 12:09 pm • by Mr_Noodle
The bad news is that it does require AppleScript but the good news is that I've posted the script and you can use it as is: viewtopic.php?p=1545#p1545

That uses a mechanism I added to the AppleScript support where the script can re-target the file that Hazel will operate on in subsequent actions (in this case, the parent folder).

I will be adding a built-in way to do this in a future release.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Make Hazel move parent folder Thu Jul 15, 2010 12:12 pm • by missdigital
Mr_Noodle wrote:The bad news is that it does require AppleScript but the good news is that I've posted the script and you can use it as is: viewtopic.php?p=1545#p1545

That uses a mechanism I added to the AppleScript support where the script can re-target the file that Hazel will operate on in subsequent actions (in this case, the parent folder).

I will be adding a built-in way to do this in a future release.


Thank you. So where do I add this AppleScript code? Sorry, I'm very new to this...

ETA: Found it. :) Thanks!
Last edited by missdigital on Thu Jul 15, 2010 12:39 pm, edited 1 time in total.
missdigital
 
Posts: 3
Joined: Wed Jul 14, 2010 5:38 pm

Re: Make Hazel move parent folder Thu Jul 15, 2010 12:39 pm • by Mr_Noodle
Select the "Run AppleScript" action, click "Edit script" and paste in the script from that article in there. No need to edit it. "theFile" is a variable that represents the file being processed at the time and gets replaced with the actual file when the script runs.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Make Hazel move parent folder Thu Jul 15, 2010 12:40 pm • by missdigital
Mr_Noodle wrote:Select the "Run AppleScript" action, click "Edit script" and paste in the script from that article in there. No need to edit it. "theFile" is a variable that represents the file being processed at the time and gets replaced with the actual file when the script runs.


Thank you! I just figured it out, and it works like a charm. I just love this program, it's worth every cent. When I get all my rules set up, it will save me hours of work.
missdigital
 
Posts: 3
Joined: Wed Jul 14, 2010 5:38 pm

Re: Make Hazel move parent folder Sun Nov 28, 2010 12:03 pm • by gcoghill
Mr_Noodle wrote:I will be adding a built-in way to do this in a future release.

Has this been added or should we still use the AppleScript method?
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Make Hazel move parent folder Tue Nov 30, 2010 11:56 am • by Mr_Noodle
It's slated for 3.0 so for now, use the AppleScript.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Make Hazel move parent folder Tue Nov 30, 2010 12:03 pm • by gcoghill
Cool, thanks.
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH

Re: Make Hazel move parent folder Wed Mar 28, 2012 4:43 pm • by papo
can you please explain how to do this on 3.0?
papo
 
Posts: 15
Joined: Wed Mar 28, 2012 4:43 pm

Re: Make Hazel move parent folder Wed Mar 28, 2012 5:07 pm • by Mr_Noodle
You need to think of it in the opposite fashion, from the top-down:

Code: Select all
If all of the following are true for any sub-file or folder
  Name contains <whatever>
Then
  Move <wherever>


Basically, if this folder has any subfiles with that name, then move the folder wherever.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Make Hazel move parent folder Tue Dec 08, 2015 1:06 pm • by oilfighter
has this feature been implemented in the latest Hazel?
oilfighter
 
Posts: 1
Joined: Sat Dec 05, 2015 7:09 pm

Re: Make Hazel move parent folder Wed Dec 09, 2015 12:55 pm • by Mr_Noodle
Yes, it's been there for a while. Hold down the option key while clicking the + button to create a new condition. That will create a nested condition with an extra pop-up where you can specify the target.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Make Hazel move parent folder Fri Dec 30, 2016 11:47 am • by JAC_151
Mr_Noodle wrote:Yes, it's been there for a while. Hold down the option key while clicking the + button to create a new condition. That will create a nested condition with an extra pop-up where you can specify the target.


I apologize, but can you explain this?

I want a rule that when new music is added to iTunes, the parent folder for the music files is copied to a cloud backup folder. I have a smart folder in the Finder that gathers all music files added to the "iTunes" file in the last 2 days (currently has 12 songs all from the same CD I just imported).

I want Hazel to watch this folder, when it sees new music files to copy the parent folder (or multiple if I added multiple albums) and not just copy the music files themselves. Any help would be appreciated. Thank you.
JAC_151
 
Posts: 6
Joined: Fri Dec 30, 2016 11:45 am

Re: Make Hazel move parent folder Mon Jan 02, 2017 12:36 pm • by Mr_Noodle
See my earlier example above. By using a nested condition, you can specify that the condition match a folder based on the files within it. The action will operate on the folder.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support