Page 1 of 1

Renaming a file or folder based on its own name

PostPosted: Wed Sep 04, 2019 3:39 am
by li0nel
So hello, here's my first post... I'm using Hazel for a few days now, and find it quite useful.
Here's something I'm trying to achieve :

I have a file lets say

Movie.2019.MULTi.1080p.HDLight.x264.AC3-TeAM_www.website.com.mkv

My idea, is to download the file in a folder and then create a new subfolder named
Movie.2019.MULTi.1080p.HDLight.x264.AC3-TeAM
And rename the video as
Movie.2019.mkv

As of now, I created a rule which deletes the _www.website.com and replaces it with nothing to create a subfolder, and the second rule renames the file, which is the easy part.

My question is :
what if the _www.website.com becomes_www.website.net or anything else? This won't work as it should, rules won't match. So I was thinking about a rule that says "anything after TeAM" gets deleted. Is it possible?
Anyone can help?

Thank you very much!

Re: Renaming a file or folder based on its own name

PostPosted: Wed Sep 04, 2019 9:59 am
by Mr_Noodle
I can't say what the pattern is based on that one file but if "TeAM" is always there then that would be one way to do it.

Re: Renaming a file or folder based on its own name

PostPosted: Wed Sep 04, 2019 10:47 am
by li0nel
Mr_Noodle wrote:I can't say what the pattern is based on that one file but if "TeAM" is always there then that would be one way to do it.


Thank you!
For now I'm just replacing the _www.website.com with empty content, but yes, TeAM would always be there, so how can I tell Hazel "hey, delete whatever is after TeAM and use the rest as a folder name" ?

Here's my current rule https://jmp.sh/cTiasxl

Re: Renaming a file or folder based on its own name

PostPosted: Thu Sep 05, 2019 9:59 am
by Mr_Noodle
Try using a pattern with a custom attribute (search the help on "match patterns" if you don't know what that is) which matches everything up to the _TEAM part. Then in the rename or sort into subfolder action, you can use that attribute.