How to copy files matching name, but not every file.

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

Moderator: Mr_Noodle

I haven't purchased Hazel yet, but I'm on the verge.

I want a rule that will go into a folder, including subfolders. Any files that have "abc123" in the name, I want copied to another folder. That's it.

Unfortunately, what ends up happening is either every file of any name that is is a FOLDER matching "abc123" gets copied, or NO file gets copied. I can't it to copy ONLY files matching the "abc123" into the new folder.

Here is my rule:
If any of the conditions are met for any sub-files or folders:
Name contains abc123
Extension is mp3
Do the following:
Run Rules on Folder contents
Copy to folder NEW FOLDER

For the rule above, the preview shows the rule drilling down into the folder, but no files match the rule, even though there are MP3 files containing the string "abc123" in the name.

Please help!
IamJAd
 
Posts: 5
Joined: Wed May 23, 2012 5:12 pm

I just tried the rule without any subfolders. Didn't work.

Now I'm thinking I'm using the NAME or FULLNAME rules wrong.

How do I get it to recognize a string (like abc123) no matter where in the file name it appears?

I can make Hazel work fine for things like file type and extensions. But not names.
IamJAd
 
Posts: 5
Joined: Wed May 23, 2012 5:12 pm

Ok, I'm playing with this more. I get the idea that I have to run two rules. However, would I do that by moving the first set of files and folders that match the first rule into a temporary file, then run rule #2 to move the file I really want into the ultimate destination, and delete the rest?
IamJAd
 
Posts: 5
Joined: Wed May 23, 2012 5:12 pm

Please read the sticky article near the top of this forum about subfolders. Do not use the "sub-files" option in the pop-up. What you are saying there is "match folders whose subfiles match the conditions below". That means that the actions will be applied to the folder, not the individual files. The article referenced above will correct that.

I'm not sure why you feel you need to move the files to a temporary location. I think you need to provide more details on what you are doing there.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

As I mentioned, I'm new to Hazel. I'm sure that once I get this concept down, most basic Hazel functions will work fine for me. I have read the sticky going into subfolders numerous times. I know how to go into subfolders. I have created test folders and read numerous previews to keep on retesting what I want, and I still have not found the magic way to make what I want happen.

I've been told that what I want to accomplish needs to be handled by two rules. If so, I don't know how to execute them so they flow consecutively as one rule. All that seems apparent to me is I identify a folder I want things performed on, then create a rule for that folder that Hazel executes.

Back to my task: I want a rule that will go into a folder, including any subfolders. Any files that have "abc123" in the name, I want copied to another folder. That's all I'm looking for. However, what ends up happening sometimes is when the folder name matches the "name contains" condition, ALL files within that folder get copied even though most of the files within that folder don't match the "name contains" condition.

I was thinking I needed a temp folder because if a folder matches the name and copies files that I don't want, I could then run a 2nd rule to sort out the files that do match from ones I don't.

Mr. Noodle, I know you live and breathe this stuff. Some of us users do not. Can you be a little more specific in how I'd want to structure the rule(s) to do what I want, and not just tell me what not to do?

I appreciate any assistance you can lend. Thanks.
IamJAd
 
Posts: 5
Joined: Wed May 23, 2012 5:12 pm

If all you want to do is copy the "abc123" files somewhere else then just add a rule like the following (in addition to the rule from the subfolders article):
Code: Select all
If all of the following are met for the file being matched
  name contains abc123
  extension is mp3
Then
  Copy to NEW folder


Basically, just write the rule as if the file was not in a subfolder. The other rule handles going into subfolders stuff. Whatever you do, do not use the pop-up which specifies subfiles unless you understand what you are doing. I somewhat regret adding that without having it more hidden so that only power-users can get to it. I'm still tempted to do that seeing how new people always want to twiddle it.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Well, without questioning it, I tried it.

It worked.

Dammit. (And thanks for your help, Mr. Noodle)

I'm not upset it worked (I'm thrilled, and I'll be buying Hazel ASAP). I'm just trying to understand how rules flow. I guess each rule filters the results down to the subsequent rule(s).

Where I'm struggling is... what if I wanted a completely unrelated rule to run on that same folder I had another rule set up on? Do I need to be concerned that the rule results will be tainted by the previous rules? Or is that only a concern when I use the condition "run rule on folder contents"?
IamJAd
 
Posts: 5
Joined: Wed May 23, 2012 5:12 pm

I think the problem is you are thinking of it as some linear flow. Just think of is like this: when Hazel encounters a file of this type, then do these actions. When it encounters a file of a different type, do these actions instead. Rules are just a series of those.

In the case of the subfolders rules, that just says, if you see a folder, then go into it and run rules. It goes into that folder and goes through each file just as if it were at the top level. If it sees one of your abc123 files, it will match that rule and execute its actions. If you add another rule to match a different file type, it will match and run for those. Where the rules interact is that only one rule can match a file, so if multiple rules can potentially match the same file, the first one in the list is the one that is matched and run. So, the main concern is to order the rules so that the right rule matches. Try using the rule preview so you can see this in action.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support