Page 1 of 1

Searching for Files within a Folder and Renaming that File

PostPosted: Sat Jul 02, 2016 3:43 am
by waqasrasheed
I have a lot of folders that have names, say xyzabc123 and they all contain many subfolders, and there is consistent file name in all of the folders called title. This file is actually a file without any extension but has a different information.

For example, I have folders named palstr347, and palstr485, and each folder has a title file in its subfolders. I want to rename the title file as title.txt in all of them. Ideally I would like to duplicate the title file and rename that title_copy file as title.txt. But just renaming that original file works fine too.

Then I would like to extract the contents of the title.txt file, to rename the palstr347 folder with the contents from its subfolder file called the title.

Re: Searching for Files within a Folder and Renaming that Fi

PostPosted: Tue Jul 05, 2016 10:30 am
by Mr_Noodle
I believe I've already responded to you in email. If not, then please indicate so here.

Re: Searching for Files within a Folder and Renaming that Fi

PostPosted: Sun Jul 10, 2016 1:15 pm
by waqasrasheed
Mr_Noodle wrote:I believe I've already responded to you in email. If not, then please indicate so here.


Thank you Here's your reply, thought it would help people.

It’s not clear to me. Do you want to rename the file or the folder at the top level. Your rule will do the latter. For the former, you need to have Hazel go into subfolders as described here: https://www.noodlesoft.com/kb/going-into-subfolders/
Then, in addition to the rule you have there, you want ANOTHER rule to rename the file.

I decided that it will help if I work here.

I've used your link above but I am not sure it helps me out much.

So yes, I want to rename the file at the top level. So let me be specific. The highlighted part below is my directory for the file called "title". title is not a folder name ... It's a file name.

palstr456/10/pdata/1/title

I know that I have to rename the title file as title.txt, then extract its text and use that to rename my folder palstr456 which is a top folder. I can go into folders alright from the link you sent above. But I am not sure if I can do what you suggested.


Using Hazel rules I can find the file title but I can't rename that file as title.txt. Instead Hazel renames the folder palstr456 as title.txt. I know why it does that, but is there a way around to make it do what I want?

Re: Searching for Files within a Folder and Renaming that Fi

PostPosted: Mon Jul 11, 2016 10:58 am
by Mr_Noodle
You'll need to post your rules as it's hard to tell without that. It seems like you want two separate rules here, though.

One to rename the file with .txt

One to rename the folder.

The latter will require use of a nested condition. See here: https://www.noodlesoft.com/kb/how-to-cr ... onditions/

Re: Searching for Files within a Folder and Renaming that Fi

PostPosted: Mon Jul 11, 2016 1:26 pm
by waqasrasheed
So here's my rules right now, just for renaming which is below:

if all conditions are met
if all conditions are met for any of its subfolders and subfiles
name contains title

Do the following to the matched file or folder:

rename with pattern title.txt

Apologies, I don't have a picture to post to show you my rules (I'm a bit of a noob on Hazel lingo still).

Re: Searching for Files within a Folder and Renaming that Fi

PostPosted: Tue Jul 12, 2016 1:29 pm
by Mr_Noodle
That's only a single rule, not two rules. And what that rule does is name the folder "title.txt". That doesn't seem right to me.

Also, you still need to rule to go into subfolders, so three rules in total.