I have a complex PDF file where Hazel is not able to extract an info from.
So I have used Python + Tika to exract that info (see  below).
Now how can I pass this value (returned from my script) to Hazel, so that Hazel is able to use it as a token to rename the file?
Alternatively I would do the final renaming in my script, but I am confused: When I pass a filename to Hazel in embedded scripts, do I pass the name prior to the renamings via Hazel or after the renamings? The order is important because if Hazel passes the filename prior to the renaming and my Python script changes the name, then how would Hazel find the file? Ideally Hazel would pass the filename after the renaming and moving so that I could do final changes to the name via my script, but I don’t know what is the case.
 My script for extracting an info out of a PDF via Python and Tika
#!/Users/ugur/.virtualenvs/pdf_tika/bin/python """ Author: Ugur Date: Created: Thursday, 4. March 2021 10:18 This script will extract `Auszugsnummer #` from bank account statements of ING like these `Girokonto_5429211318_Kontoauszug_20190601.pdf`. Usage: /Users/ugur/.virtualenvs/pdf_tika/bin/python extract_auszugsnummer.py Girokonto_5429211318_Kontoauszug_20190601.pdf See # https://github.com/chrismattmann/tika-python # https://stackoverflow.com/a/54936587/5115219 """ import sys import re from tika import parser fname = sys.argv parsed = parser.from_file(fname) (metadata, content) = parsed['metadata'], parsed['content'] matches = re.search(r"\nAuszugsnummer ([0-9]+)\n", content) auszugsnummer = matches.group(1) print(auszugsnummer)