Page 1 of 1

Folders, Subfolders, Renaming and Automator

PostPosted: Sun Sep 07, 2014 1:07 pm
by exoclient
Hi guys,

I love Hazel but I've been trying for the most part of today creating a recipe but I just can't figure this one out.

Here's what I need:

I need to be able to create under a master folder (Master) n number of Folders (let's call this Folders with a capital F). Every time I create a Folder I need to create 3 Subfolders (inside the new Folder). I manage to create that using Hazel and Automator. Here's the set up:

Hazel:

Image

Automator:

Image

So far so good. That works.

Now I'm trying to achieve a couple of things:

1) I would like for Hazel to rename the sub-folders based on the Folder name. So let's say the Folder is called Project Alpha, I would like the 3 sub-folders to be called:

Project_Alpha_subfolder1
Project_Alpha_subfolder2
Project_Alpha_subfolder3

2) Then, the second thing I'm trying to achieve is this: I would like so that every file I place under those sub-folders to be renamed using the sub-folder naming structure, so:

I upload file 3456.jpg to subfolder 1, Hazel would rename it to:
Project_Alpha_subfolder1_3456.jpg

Now, I can't for the life of me get this to work. I read the sticked post about Hazel going into sub-folders but that didn't work (and I made the mistake of running it on my main folder without testing it and now I have a HUGE mess to fix).

Any help is truly appreciated.

Thanks!

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Mon Sep 08, 2014 11:55 am
by exoclient
anyone? I could really use your help :)

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Mon Sep 08, 2014 2:02 pm
by Mr_Noodle
Please don't "bump" posts.

As for creating the folders with the project name, Hazel passes in the full path so in Automator you'll have to figure out how to break out the parts of the path.

To do the renaming part, you can try something like:
Code: Select all
    If (all) match
        If (all) match for (the enclosing folder)
            Name matches (• parent name)
    Do
        Rename (• parent name)_(name)(extension)

To get the nested condition, hold down option while clicking the + button to create a new condition. (*parent name) is a custom attribute you create. It should just have a pattern with the (anything) token.

What this rule does is capture the parent folder's name into (•parent name) which you can then use in the rename pattern.

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Mon Sep 08, 2014 2:12 pm
by exoclient
I won't bump posts. Fair enough.

However, I'm not sure I follow you.

I illustrated how I have Automator set up but that part is already working.

I'm trying to get Hazel to rename files in the subfolders. My guess is that it was done with this:
viewtopic.php?f=4&t=3854

But I can't get that to work. AS I understand I don't need Automator after the sub-folders are created.

Am I missing something?

Thanks.

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Tue Sep 09, 2014 10:52 am
by Mr_Noodle
Yes, that link describes how to do something to a folder based on something underneath it but keep in mind that that it includes items deeper down and not just the immediate children of that folder. Have you implemented what I outlined? I suggest giving that a try (on test files) to see if it works. From there you can try picking it apart to figure out how.

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Tue Sep 09, 2014 3:01 pm
by exoclient
Yeah, I followed your tutorial.

Like many folks in there, can't get it to work.

Thanks.

Re: Folders, Subfolders, Renaming and Automator

PostPosted: Wed Sep 10, 2014 11:10 am
by Mr_Noodle
Can you describe how it doesn't work? Is it not matching in preview? What happens when you run it?