Pdfinfo python2/9/2024 ![]() I use it from other scripts, Keyboard Maestro, and Hazel to generate replacement filenames, with the script/KM Macro / Hazel rule that calls it deciding when/how to use the script and the changes filenames. It is written in python, and functions a bit differently than yours, in that it accepts a single filename on stdin, reformats it, and writes the resultant new filename to stdout. I also have a script that I used for file renaming. It should also work with Hazel or Keyboard for this interesting posting! To rename all the PDFs in a given folder, you can do: pdf-rename-by-cdate.sh *.pdf If pdfinfo is not found, it won’t continue, but will tell you how to install it. If pdfinfo is unable to find a Creation Date, it will report an error but not rename the file. If you ask it to work on a file that is not a PDF, it will say “Hey, this isn’t a PDF” and skip it. I think this is basically what Finder does. If “filename (YYYY-MM-DD).pdf” already exists, it will try “filename (YYYY-MM-DD) 1.pdf” or “filename (YYYY-MM-DD) 2.pdf” etc until it does not find a conflicting file. ![]() If the original filename already has “YYYY-MM-DD” in it, then the script won’t rename it. If you give it “filename.pdf” it will rename it to “filename (YYYY-MM-DD).pdf” I was going to try to parse the info myself, but realized very quickly there are multiple formats used in a handful of PDFs that I tested, and pdfinfo worked with them all, so rather than reinvent the tool, I’m just building around one.Īnyway, it occurred to me that some folks here might be able to use this too. Note that the script requires the tool pdfinfo from poppler which you can install via brew install poppler. I called it pdf-rename-by-cdate.sh because I am very clever. Metadata = pdfrw.PdfReader(f"xxxx.pdf").Over on the Hazel forum someone was trying to rename PDFs based on the original creation date of the PDF as found in the PDF metadata which is not necessarily the same date that Spotlight or Finder will show.Īlthough the OP was making the case that Hazel should include this by default, it does not (as far as I am aware, at least), so I did what I do, and wrote a script. Pdfrw.PdfWriter().write(f"xxxxx.pdf", input_pdf) # Write to the new PDF Extract metadata from the PDF file Input_(pdfrw.PdfDict(NeedAppearances=pdfrw.PdfObject(‘true’))) # Ensure NeedAppearances is set to true ![]() If (not ‘/AcroForm’) in input_(): # Ensure AcroForm exists Here is how I am writing/uploading the PDF to Asana: Which says its fixed, but it seems that it is not working for me. I also found this: PDF Attachment Not Displaying Correctly - Bugs / Closed - Asana Community Forum Which makes me believe that its Asana’s PDF viewer, but I would love some help. And when originally saved to my local machine the form fields show up filled out in all PDF viewers I can find/use. The PDFs do contain the form fields information, I know this because when they’re downloaded or opened in a new tab (from Asana) they show the fields filled out. I have written a python script to create then upload PDFs into our Asana to optimize our process and I am having difficulties getting my uploaded PDFs to show filled out fields in the Asana preview viewer.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |