Remove part of file name during renaming

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

Moderator: Mr_Noodle

Remove part of file name during renaming Fri Jul 29, 2022 4:05 pm • by AbwehrchefVC
Good evening,

I am currently searching in vain for a way to use hazel to eleminate part of the filename when renaming.
I have already searched in the forum and also consulted the manual (e.g. Using Match Patterns in Conditions and following articles). Unfortunately without having found a solution.

About the background:

I scan my documents with ExactScan Pro or download them from the Internet into a folder monitored by DEVONthink, there the OCR is performed. From there it is moved to three folders monitored by Hazel.

When scanning (as well as downloading) I use a barcode to retrieve and sort the documents according to the following scheme:

Code: Select all
_year-sequential-no.-MC => _2022-0103-MC


I can filter this barcode with

Code: Select all
name - matches - .... Barcode (1111-1111-aa)


When downloading invoices (e.g. from Amazon, Apple etc.) I rename many documents already when saving them, these then go through the normal workflow.
The invoices then look like this, with the item always being different:

supplier_ invoice_2022-07-29_ article_Barcode

Before sorting the downloaded files into Cloud Drive/DEVONthink, I would like to remove this barcode from the file name. The rest should be kept, so:

supplier_ invoice_2022-07-29_ article

How can I realize this?

I have already tried it with Replace Text... at Name. But that doesn't work somehow, probably because of the placeholders.

Replace: _20*-*-MC with empty

How do I have to change this or which placeholders do I have to use to make it work? I have not found anything in the manual.

I get rid of the -MC, but how do I do that with the sequence number, which is different in each file.
And the year should also be flexible, so that I don't have to tackle every rule again the next year.

Many greetings
Markus
AbwehrchefVC
 
Posts: 16
Joined: Sun Jan 08, 2017 9:46 am

You need to create custom attributes to match parts of the name you want to keep, which seems like everything before the barcode. Once you have that set up, the Rename pattern can use that custom attribute, which is just the part you want.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support