How to remove a trailing space in the filename

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Your file name looks like this? "Bank statement .pdf". You want to get rid of the trailing space between the word "statement" and ".pdf", but you want to retain the space between "Bank" and "statement".

If you wish to remove a leading space (instead of a trailing space), in the file name, you will be able to easiily do it once you understand the below procedure.

You need the "Full Name" condition and the "Rename" action.
Your rule is going to look like this:
Image
In the image above, I have created a custom token called "Start of file name".
You will notice above that that in the "match" condition there is a space before the ".pdf"

Here is how you create the custom token.

Click on "Custom Text" as per the image below
Image

Give it a name as per the image below. I called the token "Start of filename"
Image

Click on "Anything" as per the image below.
Image
now click "Done" twice.

Next add the "space" followed by .pdf. like this:
Image

Finally under "Full Name matches" click the token "Start of filename", followed by ".pdf" as below.
Image

Click "Done", and run your rule. It will remove any trailing space in the monitored folder.

I assumed that the file name ends in ".pdf". If you want to do the same for any extension simply replace ".pdf" with the token "extension" as shown in the first photo above.
Trickyt57
 
Posts: 56
Joined: Tue Sep 18, 2018 12:17 am

I cannot see any of your pasted images. Only see a broken icon. Could you fix somehow?
BTW I needed to do this, so I had resorted to using another tool called A Better Finder Rename.
Paul S
Sydney, Australia
Grasshopper
 
Posts: 4
Joined: Wed Feb 21, 2024 7:37 pm
Location: Sydney, Australia


Return to Tips & Tricks - DO NOT POST QUESTIONS

cron