Page 1 of 1

Renaming a File

PostPosted: Fri Aug 18, 2017 2:09 pm
by brucel
Hello all,

I was looking for help with renaming a file using Hazel. These are business statements from PayPal. The download file name which is in a different format than our personal PayPal statements. The download file name is MSR-yyyymm.pdf. Where the y is the year and the mm is the month. What I would like to do is have Hazel change the file name to yyyy-mm PayPal Acme Statement.pdf. In other words I want Hazel to remove the "MSR-", then add a "-" between the year and month, leave a space between the month and company name and retain the .pdf extension. Any help would be appreciated. For example I will download a file to my Desktop that PayPal will name MSR-201501.pdf. I want it renamed to 2015-01 PayPal Acme Statement.pdf. I know how to get Hazel to correctly identify the file but just don't know how to manipulate the file name using Hazel.

Re: Renaming a File

PostPosted: Mon Aug 21, 2017 10:41 am
by Mr_Noodle
Look up "match patterns" in the help. You can use that feature to parse out parts of the filename and put them back together in whatever form you need.

Re: Renaming a File

PostPosted: Mon Aug 21, 2017 1:50 pm
by brucel
Mr_Noodle wrote:Look up "match patterns" in the help. You can use that feature to parse out parts of the filename and put them back together in whatever form you need.


I followed your advice Mr. Noodle and am almost there. The issue I am having now is that I am unable to figure out how to insert a "-" in the date format that PayPal uses in naming the file. For example, their date format is "201605" for May 2016. I just want to add a dash after the part of the number that is the year so that the rename date is 2016-05. This is the format I use for almost all of my various statements. I tried a different approach by using the "date created ±" thinking that the downloaded file would have the original creation date but creation date is changed to the download date. I am just wondering if I can in this case insert a dash in the existing number format. If this cannot be done it will not be a big problem because moving forward I can just use "date created ±" and modify the date by adjusting it one month backwards as I do with my other statements.

Re: Renaming a File

PostPosted: Tue Aug 22, 2017 10:39 am
by Mr_Noodle
In the rename pattern, click on the custom date attribute you created and do "Edit format". There you can re-arrange the parts of the date and also insert whatever characters you want.

Re: Renaming a File

PostPosted: Tue Aug 22, 2017 11:10 am
by brucel
Thank you Mr. Noodle. I have already been doing this. I was just trying to figure out how insert something into a downloaded file name using Hazel. In this case PayPal's file naming of statement already includes the date in the name in the format of a four number year and 2 number month. So if I downloaded the January 2017 statement part of the name would be 201701. I was just trying to figure out if Hazel could could add a "-" between the the numbers representing the year and the month. In this example between the 7 and the 0 in the same way a sophisticated file renaming utility would. Let’s say someone did not back up their computer and had to download 7 years of old bank statements for their business and wanted to use Hazel to rename those statements without using a separate file renaming program. The custom date attribute feature is great and I use it every month when I download my previous month's statements. In my case I had to download statements from 2016 and this year up to last month. So I just used Name Mangler to do the renaming. My primary reason for asking the question is that I wanted to know if I could insert something into a file's name using Hazel in case I experienced a similar need in the future.

Re: Renaming a File

PostPosted: Wed Aug 23, 2017 10:57 am
by Mr_Noodle
Can you post your rule? It should be doable as I described so I'm not sure where you are running into problem.

Re: Renaming a File

PostPosted: Wed Aug 23, 2017 3:12 pm
by brucel
Mr. Noodle,

I am not sure how to post a rule. I did not find a way to export an individual rule. Also there is a small amount of personal information in one part of this rule that I would need to omit before posting. I tried dragging a screenshot but do not have permissions to post any image that is not a weblink.

Re: Renaming a File

PostPosted: Thu Aug 24, 2017 10:18 am
by Mr_Noodle
You need to use an image hosting site. imgur.com is one example though if you use something like Dropbox you can also post links through that.

Re: Renaming a File

PostPosted: Thu Aug 24, 2017 11:34 am
by brucel
Hi Mr. Noodle,

Here is my rule: https://www.dropbox.com/s/06gy0ofw8ngp697/Rule.png?dl=0

This works with downloading a previous month's statement because of https://www.dropbox.com/s/ncsr3m6i64oml1q/Date%20Modification.png?dl=0.

What I am trying to do is modify the part of the name PayPal uses in its file naming convention so that I will not have to manually rename a file. As I mentioned in the previous post I will download a file to my Desktop that PayPal will name MSR-201501.pdf. I want it renamed to "2015-01 PayPal Keiko Statement.pdf" by removing the "MSR-", then adding a "-" after the "2015" to separate the year and month then append this with "PayPal Keiko Statement.pdf". In other words I could not figure out how to get Hazel to insert a "-" in a specific place in an file name.

Again this is not critical for my current use of Hazel but I would like to know if I can insert letters, numbers and characters at a certain position in a file name for future reference. I also realize that if I knew Apple Script it would probably be fairly easy to do this with an Apple Script.

Re: Renaming a File

PostPosted: Fri Aug 25, 2017 10:46 am
by Mr_Noodle
Click on "Date created" and do "Edit Format". Send me a screenshot of the resulting window.

Re: Renaming a File

PostPosted: Fri Aug 25, 2017 11:07 am
by brucel

Re: Renaming a File

PostPosted: Fri Aug 25, 2017 3:44 pm
by Mr_Noodle
Looks like you figured out how to format the date. One thing I should point out, though, is that you are using date created, which may or may not be related to the date in the name of the file. If you want to use that date, you need to use match patterns and custom attributes to pick out the parts from the name.

Re: Renaming a File

PostPosted: Fri Aug 25, 2017 8:26 pm
by brucel
Mr_Noodle wrote:…If you want to use that date, you need to use match patterns and custom attributes to pick out the parts from the name.


Yes Mr. Noodle that is what I was unable to figure out. Is there a help article that would explain this?

Re: Renaming a File

PostPosted: Mon Aug 28, 2017 11:04 am
by Mr_Noodle
Searching for "match patterns" in the help as previously suggested should bring up the relevant chapter. Also, search the support site as there are other articles there that might help you.

Re: Renaming a File

PostPosted: Mon Aug 28, 2017 11:44 am
by brucel
Will do Mr. Noodle.