shortening a file name

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

Moderator: Mr_Noodle

shortening a file name Sat Aug 31, 2024 6:25 am • by AbwehrchefVC
Hello,

I need some help with renaming a file name or rather shortening a file name.

Some file names are automatically generated from the content in my rules.
However, there are exceptions to this, which I rename in the Finder according to the following pattern:

Amazon_Rechnung_2024-08-31_Product_Barcode.pdf

The barcode always has the same structure:

Year-consecutive number-initials, e.g. _2024-0398-MC

As these invoices are invoices that I download, I only need the barcode automatically generated by Typinator for sorting into my Hazel rule.
After that, it should ideally be deleted before the file is moved to its destination.

I have already searched the forum and also read through the match patterns section in the instructions, but I can't really get any further with it.
I have also tried several variants with Replace Text, but they didn't work.

Even two friends who have been Hazel users for years have not found a solution.

What I have in mind is something similar to the A Better Finder Rename app, where I can simply shorten file names by 13 characters from the back.

How do I have to/can I do this in Hazel? I've also tried Replace Text, but that didn't work.

I am happy to receive tips

Best regards
Markus
AbwehrchefVC
 
Posts: 17
Joined: Sun Jan 08, 2017 9:46 am

Re: shortening a file name Sat Aug 31, 2024 11:50 am • by HaubenTaucher
Hej Markus and greetings to all others...,
that is a good question which i can´t answer, but often have similar issues...
I hope you get some feedback here to your question from Mr. Noodle or someone else...

Greetings
Rolf
Happy wife .... Happy life... :D
HaubenTaucher
 
Posts: 19
Joined: Sun Oct 23, 2016 8:23 am
Location: Germany / OWL

Re: shortening a file name Tue Sep 03, 2024 8:38 am • by Mr_Noodle
You can set up a match pattern like (• name prefix)(char)(char)...

where you have 13 characters after the custom name prefix attribute that you create to match anything. Then rename with the custom attribute.

Note that version 6 does have an option to limit the length of an attribute (truncate), but this limits it to X characters, not the last X characters from the end.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support