sync only when file/folder present?

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

sync only when file/folder present? Mon Mar 21, 2016 5:50 am • by patmos
I want to use Hazel to keep Wordpress plugins updated across a number of local development environments. I can already sync the entire contents of a master folder to various locations, but what I really want to do is have Hazel sync files only when the file is already present in my destination folder.

Presently, I have the following option invoked:
Image

But what I really need, and that I can't find, is something like, "If the file doesn't exist, don't copy it."

Is there a way to do this?

p.s., I really wish Hazel was a standalone app. Dealing with things in the tiny window of the System Preference is a pain in the backside.
patmos
 
Posts: 4
Joined: Mon Mar 21, 2016 5:38 am

Re: sync only when file/folder present? Mon Mar 21, 2016 11:01 am • by Mr_Noodle
You can set it to not copy the file or is that somehow not suitable?

As for the window size, do you have a large number of rules? If so, can you describe them in more detail?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: sync only when file/folder present? Tue Mar 22, 2016 3:21 am • by patmos
Maybe I was unclear.

If the file exists, I want it to copy. But if it doesn't exist, I don't.

Basically, I have a folder that serves as an master directory for plugins. When I get an update, I copy it there. This then triggers my rules, copying that file to my plugin folders of various local Wordpress installs.

Hence I don't have to copy the new plugin to all these installs (20+) one by one.

This works perfectly, but it also means that I copy ALL files/folders in my master to all these plugin folders of my Wordpress installs.

The problem is that I don't use certain plugins in all installs.

So I'm basically looking for a way that Hazel would check all these plugin folders in my installs and only copy a new file dropped in master IF that file/folder already exists in a given plugin folder of a local install.

In that way, I'm keeping my plugins up to date globally, but not copying ALL the plugins from my master folder to all plugin folders of all local installs.

Does that make sense?

On window size, yes, I guess I have a number of rules. The Sys Preferences window makes managing these somewhat difficult, because it's so small. Much better would be Hazel as a standalone app.

For example, in the example above I'm copying to wp-content/plugins in a number of installs. Because the window is so small, I cannot easy tell which install I'm copying to after I add them:

Image
patmos
 
Posts: 4
Joined: Mon Mar 21, 2016 5:38 am

Re: sync only when file/folder present? Tue Mar 22, 2016 3:22 am • by patmos
patmos
 
Posts: 4
Joined: Mon Mar 21, 2016 5:38 am

Re: sync only when file/folder present? Tue Mar 22, 2016 10:57 am • by Mr_Noodle
I think you'll need to write a script to do that logic as there's no way to set up conditions to look in two different folders like that.

As for window size, it seems you are referring to a lot of actions, not rules. In that case, the window does grow to accommodate them all and when it runs out of room (i.e. hits the screen limits), it allows you to scroll. Not sure how having Hazel being an app can change that.

Lastly, possible non-Hazel solutions (I'm in the midst of reworking my Wordpress install now which is why I bring this up):

- Use WP's multisite functionality. Allows you to have one WP install with multiple sites. Can control everything from one control panel and I believe you can have different plugins activated/deactivated on a site-by-site basis.

- If you can find a Debian/Ubuntu machine to test this out on (or find a way to unpack the official Wordpress package), it does an interesting thing where you install WP in one place. The wp-config file actually checks which domain is being accessed and then looks for a config file elsewhere based on that. Each config can be totally separate (different database, etc.) but still share the same file installation. Again, plugins can be activated/deactivated on a per site basis since that info is stored in the database. Note that each site has its own admin interface you have to log into (which is what you have now).

Something to think about at least.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: sync only when file/folder present? Wed Mar 23, 2016 10:24 am • by patmos
Thanks.

There are a number of ways I could do this. I was just looking for the easiest way, and given that Hazel is great for syncing folders, I thought it may contain a way to sync only the parts of the master folder that are present in the destination. You already have an option for actions, "If file exists: rename / replace / don't copy." In effect I need the additional option, "If file does not exist: don't copy."

Maybe this would be useful to others and could be added in an update?

On Wordpress, I do Wordpress development, so use Vagrant and have all my sites in discreet virtual machines. But multisite is cool, in some circumstances.

I could probably Applescript what I need. But the logical route is to use Git, which is probably the way I'll go when I get time.

Thanks for your replies, and the great software.
patmos
 
Posts: 4
Joined: Mon Mar 21, 2016 5:38 am

Re: sync only when file/folder present? Wed Mar 23, 2016 1:54 pm • by Mr_Noodle
I've added it to the feature database though I have to say that it's not a frequently requested feature. If more people come out of the woodwork with other uses cases for it, then that would help. Nonetheless, it's under consideration.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion