Stripping dates

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

Moderator: Mr_Noodle

Stripping dates Wed Aug 05, 2020 6:32 am • by kelpie
Hi

Could someone help a befuddled man sort this issue, please?

I have Hazel add dates to the beginning of certain files, usually today's date. On some occasions I later get Hazel to move that file and I would like the date removing in the process. I have tried several things with the rename option but to no avail.

I would like the file "2020-08-05 - textfile.txt" to become "textfile.txt" upon being moved.

I'm sure it is easy but it is eluding me.

Many thanks

Pat
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Wed Aug 05, 2020 9:34 am • by EdBurke
Here's a basic rule for you to try...
Image
EdBurke
 
Posts: 28
Joined: Wed Apr 18, 2012 6:58 am

Re: Stripping dates Wed Aug 05, 2020 10:01 am • by kelpie
Hi
Many thanks for your reply. I'm not sure if this achieves what I was looking for though.

I just need to remove the date part of the filename, the first thirteen characters, regardless of what that date is.
Hazel will have added the date at some time in the past and then will be asked to move the file based on criteria other than the date, at that point the date becomes irrelevant and needs removing.

Thanks again

Pat
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Wed Aug 05, 2020 10:41 am • by Mr_Noodle
The suggestion is correct. It takes apart the name, storing the date part into the first custom attribute, and the rest of the name in the second one. It then only uses the second one when renaming. Look up "match patterns" in the manual for more details on how this works.
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Stripping dates Wed Aug 05, 2020 10:43 am • by EdBurke
For me, running the rule on a file named 2020-08-05 - textfile.txt resulted in a file named textfile.txt

Is that what you wanted?
EdBurke
 
Posts: 28
Joined: Wed Apr 18, 2012 6:58 am

Re: Stripping dates Wed Aug 05, 2020 11:23 am • by kelpie
Thanks for the replies.
Yes, that's what I wanted, I need to spend some time looking at it and trying to get my head round it.

Cheers

Pat
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Mon Aug 17, 2020 5:22 am • by kelpie
Hi

Just thought I'd add a note of thanks. I've found time to look into this and have now understood what's going on. Your example works as you described and I now have it functioning correctly in my rules.
Thanks again

Pat
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Mon Aug 17, 2020 5:32 am • by kelpie
Could I ask a further question? Is there a way to use the match patterns in other rules without rebuilding them in each one? A kind of pattern library, as it were?
Thanks
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Mon Aug 17, 2020 9:56 am • by Mr_Noodle
No, you'll need to re-create them. Where do you need to re-use them? Other rules in the same folder? Rules in different folders? Are the folders under a common folder?
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Stripping dates Mon Aug 17, 2020 10:53 am • by kelpie
Mr_Noodle wrote:No, you'll need to re-create them. Where do you need to re-use them? Other rules in the same folder? Rules in different folders? Are the folders under a common folder?


Mostly other rules in the same folder.
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Tue Aug 18, 2020 9:19 am • by EdBurke
Could I ask a further question? Is there a way to use the match patterns in other rules without rebuilding them in each one? A kind of pattern library, as it were?

I've had success duplicating rules and then modifying a parameter or two in the copy. When rules are dragged to a different folder a copy of the rule is created in that folder.
EdBurke
 
Posts: 28
Joined: Wed Apr 18, 2012 6:58 am

Re: Stripping dates Tue Aug 18, 2020 9:39 am • by kelpie
EdBurke wrote:
Could I ask a further question? Is there a way to use the match patterns in other rules without rebuilding them in each one? A kind of pattern library, as it were?

I've had success duplicating rules and then modifying a parameter or two in the copy. When rules are dragged to a different folder a copy of the rule is created in that folder.


Thank you, I'll have a play round
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Tue Aug 18, 2020 11:10 am • by Mr_Noodle
Do they need to be separate rules? Can you post some examples?
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Stripping dates Tue Aug 18, 2020 11:31 am • by kelpie
Mr_Noodle wrote:Do they need to be separate rules? Can you post some examples?


Just simple filing rules based on tags:

If the file type is PDF and has the tag 'sheet music' strip the date from the filename and move to the folder 'Drobo/sheet music'

Nothing elaborate at this stage, I have several rules like this that move files to folders based on the tags that have been assigned.
kelpie
 
Posts: 20
Joined: Mon Mar 14, 2011 7:08 pm

Re: Stripping dates Wed Aug 19, 2020 9:59 am • by Mr_Noodle
If they all have the pattern of match a tag then sort into a subfolder with that tag, then it might be able to be condensed into a single rule. Is there only one tag on these files? Do they have to match a specific set of tags?
Mr_Noodle
Site Admin
 
Posts: 11240
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support