Help. Script to Batch Change PDF Title to its File Name
Hi everyone, I have been trying to figure out a way to batch convert PDF Titles to their file names (or in sequence from a txt file). My ultimate goal is to find a way to batch change the Titles of PDF's, the solution for which, I have not been able to find. So, I thinking about trying to come at it from another angle. I can batch change file names easily enough with an app, so I'm hoping that someone can help with a script that can batch change PDF Titles to match their file name. Anyone have any ideas?
Thanks,
Darryl
Howdy, Stranger!
Comments
Darryl, I think this little project is just what you want.
GitHub - metebalci/pdftitle: a utility to extract the title from a PDF file.
From the Readme, "you can use this utility to extract the title and rename the files if you want."
I've not tried this project.
Will Simpson
My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
kestrelcreek.com
Thanks for the link Will. I've seen this one, but it's going the opposite way I'm looking to go (Title to File Name, rather than File Name to Title). I'm really at a loss on this one. May have to just resort to manually changing the titles (but with some assistance from KM). That's what I have done already, but even with KM+manual process, it still takes quite some time for a 100+ PDF's.
Darryl, I'm a little dense. Do you want to switch all the PDFs, so the titles displayed when viewing them are the file names? You seem to be asking for something that has never been tried before in the history of the internet.
Have your seen ExifTool by Phil Harvey? I learned about this app via macos - How to change a PDF's title? (not file name) - Stack Exchange.
The key syntax is
exiftool -Title="New Title" /path/to/filename.pdf
. Using looping actions in Keyboard Maestro or via the shell, this could be done all in one swoop. I've not tried exiftool, but it looks awesome. It seems only to edit the metadata of the PDF and not the actual PDF. Probably no help.This is a tough one. There is a tool called Coherent PDF Command Line Tool which has the power to do what you want, but the placement of the actual text in the PDF is real fiddly, assuming you don't want only to change the metadata. Here's the syntax,
➜ cpdfdemoarm ./cpdf -topline "Line of text" ../test.pdf -o ../test4.pdf
Blasphemy of all blasphemies, Microsoft Word can easily change the PDF title text, and Keyboard Maestro could probably be scripted to help with this. Do you have Word?
Will Simpson
My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
kestrelcreek.com
Haha!
This might be the solution. Just have to get my head around how to use exiftool.
Yes, I do have Word, didn't know Word could change PDF titles.
Thank you for your help with this!