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: 58
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

This was a brilliant solution to a problem I was having. I had a folder where some filenames started with YYYY-MM-DD and I wanted to rename them to start with YYMM. Your example allowed me to achieve this. Thank you for the contribution to the community.;
quikatb
 
Posts: 21
Joined: Tue Mar 26, 2013 4:34 am

quikatb wrote:This was a brilliant solution to a problem I was having. I had a folder where some filenames started with YYYY-MM-DD and I wanted to rename them to start with YYMM. Your example allowed me to achieve this. Thank you for the contribution to the community.;


In this case, wouldn't it ne easier just to use date pattern (recognize date and save it with a different formatting)?
kingshill
 
Posts: 19
Joined: Sun Apr 23, 2017 3:11 pm

I had a problem, and this was a great way to solve it. I wanted to change some of the filenames in a folder that began with YYYY-MM-DD to start with YYMM. I was able to accomplish this because of your example.
Jesse Mueller
 
Posts: 1
Joined: Wed Nov 06, 2024 11:23 am


Return to Tips & Tricks - DO NOT POST QUESTIONS