Page 1 of 4

Rename a file using the information contained in a pdf.

PostPosted: Mon Oct 03, 2022 9:14 am
by hercut
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.

Re: Rename a file using the information contained in a pdf.

PostPosted: Mon Oct 03, 2022 9:51 am
by Mr_Noodle
You can use a match pattern to match the date. Consult the manual as there are more details there.

Re: Rename a file using the information contained in a pdf.

PostPosted: Mon Oct 03, 2022 10:03 am
by hercut
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.

Re: Rename a file using the information contained in a pdf.

PostPosted: Tue Oct 04, 2022 9:21 am
by Mr_Noodle
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?

Re: Rename a file using the information contained in a pdf.

PostPosted: Tue Oct 04, 2022 11:09 am
by hercut
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 :(

Re: Rename a file using the information contained in a pdf.

PostPosted: Wed Oct 05, 2022 9:59 am
by Mr_Noodle
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.

Re: Rename a file using the information contained in a pdf.

PostPosted: Wed Oct 05, 2022 10:09 am
by hercut
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?

Re: Rename a file using the information contained in a pdf.

PostPosted: Thu Oct 06, 2022 10:40 am
by Mr_Noodle
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.

Re: Rename a file using the information contained in a pdf.

PostPosted: Thu Oct 06, 2022 10:57 am
by hercut
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 ...

Re: Rename a file using the information contained in a pdf.

PostPosted: Thu Oct 06, 2022 11:59 am
by hercut
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!

Re: Rename a file using the information contained in a pdf.

PostPosted: Wed Oct 19, 2022 11:44 am
by hercut
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

Re: Rename a file using the information contained in a pdf.

PostPosted: Thu Oct 20, 2022 10:03 am
by Mr_Noodle
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?

Re: Rename a file using the information contained in a pdf.

PostPosted: Thu Oct 20, 2022 10:14 am
by hercut
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

Re: Rename a file using the information contained in a pdf.

PostPosted: Fri Oct 21, 2022 9:29 am
by Mr_Noodle
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.

Re: Rename a file using the information contained in a pdf.

PostPosted: Fri Oct 21, 2022 9:34 am
by hercut
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.