![]() ![]() All of these options were created for various workflows where I wanted to use this script. It supports a few command line flags to specific date or date and time to use in creating the new filename, to use the file’s creation date instead, to also lowercase the entire filename, and a flag to indicate that if the file in question actually does not exist (or is not a regular file) then generate an error rather than producing a new filename. ![]() 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. It could also be much simpler, if it just ran as a simple web server.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. That way the process (either WSL or Mingw) could continue running, and process PDFs based on requests received, and returning the output to the caller. It would be nice if the Poppler team built a mmap IPC convention for processing PDF files. I’m guessing the WSL/Ubuntu version is 64 bit for instance. If you need perfect support for QT and other missing features of our mingw Windows built version, then WSL might be the best way to go. So in some ways our work on windows compiling can be better – it gives you the latest version. If you’re a developer, you can still start the ubuntu based poppler tool(s) using the wsl command: “wsl pdftocairo …”Īs it turns out though, your poppler version will be limited to a given distribution of Ubuntu at the time. Then you can simply install “sudo apt install poppler-utils”. You can enable WSL and install Ubuntu if you are not using the “S” edition of Windows. Windows Subsystem for Linux (WSL) is a great option for many windows users and developers. PDFToCairo – For exporting to images types, including SVG!.PDFToHTML – Which I use with the -xml option to get an XML file listing all of the text segments’ text, position and size, very handy for processing in C#.I suggest you use the -Layout option for getting the content in the right order. PDFToText – Extract all the text from PDF document.So now, you can run the following utilities from Windows! Update: MSVC isn’t very well supported, these days the download is based off MinGW. So after years of pain, I jumped on oDesk and contracted Ilya Kitaev, to both compile with Microsoft Visual Studio, and also prepare automated tools for easy compiling in the future. Getting the executables (exe) and/or dlls for the latest version however is very difficult on Windows. Poppler is targeted primarily for the Linux environment, but the developers have included Windows support as well in the source code. It’s an open source set of libraries and command line tools, very useful for dealing with PDF files. I have been using the Poppler library for some time, over a series of various projects. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |