Page 1 of 1

Flatten folder structure

PostPosted: Fri Jan 11, 2013 12:26 pm
by spaceship
This is the reverse of the usual. http://www.photosync-app.com is hard coded to create

~/Desktop/iPad mini/Camera Roll/IMG_0042.JPG

but I want the images directly on the desktop and no empty folders lying around. How to do it?

Re: Flatten folder structure

PostPosted: Fri Jan 11, 2013 2:38 pm
by scottfwalter
How about this, set this rule up:

Code: Select all
If all of the following conditions are met for any of its sub-files or folders

Kind is not folder


Run the shell script

Code: Select all
find $1 -type f -name '*' -exec mv -n \{\} /Users/scott/sandbox/dest \;


You will need to hard code the destination folder in the script like I have above. If you have the filename duplicated in your hierarchy folder structure the above script will only move the first one. The "-n" option means dont overwrite if it exists in the destination.

Public Service Announcement - Do this on test folders first before trying it out on your real data

Re: Flatten folder structure

PostPosted: Fri Jan 11, 2013 2:52 pm
by spaceship
Thanks!

It looks like this roll would go on the "iPad mini" folder. But if I use another rule to get rid of the folder, the rule will be disabled and won't fire when PhotoSync re-creates the folder.

Re: Flatten folder structure

PostPosted: Fri Jan 11, 2013 11:24 pm
by ecormany
you should attach your set of rules to ~/Desktop. then you can have Hazel match folders on the desktop to flatten and zap. you can have it do that for all folders (potentially dangerous!) or only ones that match certain names.

i posted how to make a set of general flattening rules in another thread: viewtopic.php?f=2&t=1531&hilit=+push#p6168

hope that helps!

Re: Flatten folder structure

PostPosted: Mon Jan 14, 2013 1:17 pm
by Mr_Noodle
BTW, please do not post questions to the Tips forum. The sticky article up top indicates this.

If you have Hazel going into subfolders, just have another rule to move the files to a folder, which effectively flattens it. You can then add a rule to remove the empties. You can go by size or number of subitems.

Re: Flatten folder structure

PostPosted: Mon Jan 21, 2013 11:40 am
by pattulus
I've tried this rule and it works partially here.

I also use PhotoSync and have an iPad and an iPhone.
This is what my folder structure looks like:

Image

I think the shell script doesn't work correctly with this setup.

I works for the "Nano" folder but ignores the "HAL 9000"
folder – although the rule is marked as matched and I get a
notification it doesn't move the images.

When I renamed the folder to "HAL9000" without space it works.

Re: Flatten folder structure

PostPosted: Tue Jan 22, 2013 1:37 pm
by Mr_Noodle
My suggestion is to not use the shell script. Read the sticky article at the top of this forum on subfolders as that should do what you need.

Re: Flatten folder structure

PostPosted: Tue Jan 22, 2013 2:20 pm
by pattulus
Thanks for inspiring me to give it another shoot. I tried exactly that yesterday with no success.

Today it worked:

Rule 1:

Image

Rule 2:

Image

The odd part I can't explain is why this one – which I tried yesterday – didn't work as rule 2:

Image

Re: Flatten folder structure

PostPosted: Tue Jan 22, 2013 3:27 pm
by spaceship
You reminded me that PhotoSync doesn't have to create its folders on the Desktop, so I can just put them somewhere I don't look, and stop worrying about removing them! Since I don't use albums on the iPad this also allows me to attach the rule directly to the folder containing the images. Works marvelously:
Image

Re: Flatten folder structure

PostPosted: Tue Jan 22, 2013 3:32 pm
by pattulus
spaceship wrote:You reminded me that PhotoSync doesn't have to create its folders on the Desktop, so I can just put them somewhere I don't look, and stop worrying about removing them! Since I don't use albums on the iPad this also allows me to attach the rule directly to the folder containing the images. Works marvelously:


Good to hear. I still have to apply the rule to the enclosing folder since I sync 2 devices… sadly the rule won't work there. Otherwise I could make use of it in other folders filtering for different kinds of criteria, the "kind: not Folder" rule is to broad for other use cases.

Re: Flatten folder structure

PostPosted: Wed Jan 23, 2013 3:04 pm
by Mr_Noodle
Not sure why the other rule didn't work. Read the stickied troubleshooting article. I'm guessing there might be some issue with Spotlight such that the file wasn't being identified as an image.

Re: Flatten folder structure

PostPosted: Mon Jan 28, 2013 3:05 pm
by pattulus
You guess was correct – I move the folder in question to one of the few parts of my system were I disabled Spotlight.