Strip files from folders

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

Moderator: Mr_Noodle

Strip files from folders Wed Oct 22, 2014 3:55 pm • by biasuz
Hi there everyone.

I wish to create a rule to apply in a folder (like the example mainfolder below) to collect all files there are on subfolders and put them back in the main folder, striping all file hierarchy and leaving them at the mainfolder level.

Let me clarify:

path:/mainfolder

I would like to strip all files from their folders and move them to the manifolder, deleting remaining empty folders.

files on path/mainfolder/subfolder1/*lots of files* -> move files to path/mainfolder -> delete folder that is empty.

Is this possible?

I had issues with apply on folder rule.
biasuz
 
Posts: 5
Joined: Wed Oct 22, 2014 3:46 pm

Re: Strip files from folders Thu Oct 23, 2014 12:15 pm • by Mr_Noodle
See the sticky article about going into subfolders. You'll need that to get Hazel to descend down to each file. Then you create a separate rule to move the files to the one folder. Then, to cleanup, you can set up a rule to remove empty folders. I think that should do it.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Strip files from folders Thu Oct 23, 2014 4:17 pm • by biasuz
I read the sticky article.

not working for me.

But there is a variable I did not stated.
I never know the name of the subfolder... they are random.

Can you post an example of how to build this rule?
biasuz
 
Posts: 5
Joined: Wed Oct 22, 2014 3:46 pm

Re: Strip files from folders Thu Oct 23, 2014 4:31 pm • by biasuz
i created an youtube video to explain the issue.

check it out.

thanks.

https://www.youtube.com/watch?v=q-r3X-7fFe0
biasuz
 
Posts: 5
Joined: Wed Oct 22, 2014 3:46 pm

Re: Strip files from folders Thu Oct 23, 2014 9:24 pm • by biasuz
Hello everyone.

At first I reluctant to believe this function was not working properly, so I tried all possible combinations at the top and bottom. My conclusion is that the "apply rules on folder content" is probably bugged in this version.

For those who cannot wait, I think the simplest solution is to call an automator script to do the job.

Rule:
If kind is Folder
If size is greater than 0 bytes

Do the following to the match file or folder
Run automator workflow


Whereas the automator workflow is quite simple. Just 2 itens.

1. Get folder contents, with repeat for each subfolder found checked
and
2. Move finder items to folder you want, in my case, the full path of folder.

than add a second rule

Rule:
If kind is Folder
If size is 0 bytes

Do the following to the match file or folder
Move to trash

Problem solved.
biasuz
 
Posts: 5
Joined: Wed Oct 22, 2014 3:46 pm

Re: Strip files from folders Fri Oct 24, 2014 12:24 pm • by Mr_Noodle
Looking at your video, the rule to go into folders is meant to match and operate on folders. You need to create another rule with the actual logic to match and process the files within. They are separate rules. Also, as outlined earlier, you need yet another rule to match the empty folders to remove them.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Strip files from folders Fri Oct 24, 2014 6:01 pm • by biasuz
This dialog is just plain ludicrous.

Please, kindly, with sugar on top do provide a BETTER EXPLANATION.
WITH FULL DETAILS AND A WORKING EXAMPLE!

I've seldomly used this software, but even on the the glued post, there is no working example of this, even as a proof of concept. Not only that, the first immediate post afterwards asks for more details and fails to work it out and afterwards, none is provided.

I've already understood that you need an individual rule for each logic applied to the files.

I know this sounds stupid for you. But it is not entirely self explanatory.
otherwise there would have been so many questions regarding this.
There's even videos resorting to bash scripts on hazel because it is not self evident.

Kindly provide a working example

Please don't informe me yet again that I need a individual logic for each thing. That piece of information is already crystal clear since I've created a second rule just to empy the folder.

Yet again I repeat myself and ask, yet again, for you to kindly write an WORKING EXAMPLE.

Thank you.

PS
"Looking at your video, the rule to go into folders is meant to match and operate on folders. You need to create another rule with the actual logic to match and process the files within. They are separate rules. Also, as outlined earlier, you need yet another rule to match the empty folders to remove them."

The rule on the video is
If kind is folder

Apply on folder contents
tag red
biasuz
 
Posts: 5
Joined: Wed Oct 22, 2014 3:46 pm

Re: Strip files from folders Mon Oct 27, 2014 3:07 pm • by Mr_Noodle
The article shows you a rule. You use the rule as is. All it does it tell Hazel to go into subfolders. Any other logic, such as that to actually do what you were asking, you have to add yourself and do so in a different rule. If you follow those instructions, you'll get much farther. Create your rules as if everything was at the top level of the folder. Then add the subfolder rule. That should do it.

Yes, it's confusing, but it's a tricky problem. Also, it's probably the most destructive thing you can have Hazel do, so I'd rather have people ask questions then to have it too easy to shoot themselves in the foot. It's important that people do this with an actual understanding of what's going to happen as there have been cases where people really messed things up in a bad way doing this.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron