Rename a file using the information contained in a pdf.

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Hello,

Would it be possible to ask Hazel to search for a line with the same name as a file, but not the same date in a pdf in order to rename the file by the date in the pdf?

You will quickly understand.

I have my account statement, and I would like the invoices (already having a date) to be renamed with the date of the statement.
Easier to search later.

Thank you very much for your help.
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

You can use a match pattern to match the date. Consult the manual as there are more details there.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:You can use a match pattern to match the date. Consult the manual as there are more details there.


If I don't say anything stupid, would match paterne work with one rule per line? Or one rule will be able to manage all the lines?

Or I can have several files (invoice) and each one will be analyzed thanks to the PDF (bank statement)?

My bank statement looks like this:
Image

So for the second charge, "TotalEnergies" I have a bill that matches.
Hazel will be able to come and see the date in the pdf (the statement) and modify the date in the file (the invoice)?

I have moved on, but I can't find a way to work on two files in hazel.

I can find my line very well, but I don't know how to use it to work on my second file.
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

Oh, I didn't realize that you wanted to name a different file from the one being read. You'll need to write a custom script for that. Is there no way to get that from the file being renamed?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Oh, I didn't realize that you wanted to name a different file from the one being read. You'll need to write a custom script for that. Is there no way to get that from the file being renamed?


Unfortunately not.
That's why I'm looking to do this.

The invoice date is different from the statement date.
So to save a little time, it is easier to have the date of the statement to find the invoice.

I first file my invoices in a year folder and when I sort, I rename with the date of the statement.
This becomes tedious after a while.

Concerning the script, is there an easy way to do it?

I had anticipated your answer and started looking for the apple shortcut. But, I'm absolutely not good at it and I don't have much time to spend on it :(
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

You can try using tables. You'd need to get the data into tabular form but once there, you can set up a custom table attribute to do lookups on it.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:You can try using tables. You'd need to get the data into tabular form but once there, you can set up a custom table attribute to do lookups on it.


The problem is always the same knowing that I have to work on two different files?
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

I think it's unavoidable that some sort of custom logic needs to be done here. Whether it's a script or some program to convert the file into data usable by Hazel.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I think it's unavoidable that some sort of custom logic needs to be done here. Whether it's a script or some program to convert the file into data usable by Hazel.



Both files are pdfs readable by hazel.
But you confirm me that Hazel can't work with tokens from a pdf (the name of the invoice) on another pdf (the statement).

I don't know how to script, I'm currently trying to do what I want with shortcuts but I can't find a way to find the name of the pdf in the other pdf...

I apologize between my pathetic English and the complexity of explained ...
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

I just figured out, you can integrate a search on an external excel.
I'm doing some tests, but it seems heavy.


Still, adding to Hazel a way to create tokens via another file would be awfully cool!
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

But I have a problem.
Knowing that my table has lines with the same amount and label I have only the date that changes.
I have to find the right line thanks to the month of the date.

So I ask hazel to find me the table's libel:
libele matches with the table (unamed2 column 2)

once the value is found, if I understood well it corresponds to the row of the table.
but impossible to create a token with the row of the array.

Like, uname2 match custome text, in order to set the custome text to a new value.
If I do that, the array starts from my function.

Translated with www.DeepL.com/Translator (free version)

Image
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

I'm a bit lost here. Can you show me an example line from your table along with the column names?

As for your screenshot, can you replicate it and if so, send me a video of it?
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:I'm a bit lost here. Can you show me an example line from your table along with the column names?

As for your screenshot, can you replicate it and if so, send me a video of it?



Image

My table is .txt, because excel bug ...
Code: Select all
Date   Libellé   Montant
03/01/2022   Bouygues Telecom   -12,99
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

There's something wrong in that you select "unnamed" but I don't see it in any of your conditions. I'm not sure how you got it into that state. Also, it seems like you keep creating new table attributes instead of using the same one. If you keep creating new ones, they will not be linked.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:There's something wrong in that you select "unnamed" but I don't see it in any of your conditions. I'm not sure how you got it into that state. Also, it seems like you keep creating new table attributes instead of using the same one. If you keep creating new ones, they will not be linked.



It is on the second to last line.
libele matches

The other lines above are not useful, they are tests to get details.
hercut
 
Posts: 39
Joined: Fri Dec 17, 2021 11:44 am

Next

Return to Open Discussion