A-PDF Preview and Rename

A-PDF Preview and Rename

You’re often faced with a delimma where you get a set of files from somewhere with the filenames not matching the contents. They may be chapters from a book where it would be good if the title matched the chapter name. We’re previously covered a post on A-PDF Rename, a software which can use the PDF Title metadata to batch rename a set of files. But for complex tasks like where the Title metadata has not been set for some files, A-PDF Rename fails. I’d been using Linux script to workaround this for months. Here’s my script to batch rename such files (may need to be tweaked for your file):

if [ "$1" == "" ]
        echo $1
for file in *pdf
  chap=`pdf2txt -p 1 "$file" | grep 'CHAPTER' -A3 | sed '2q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//'`
  if [ "$chap" == "" ]
        name=`pdf2txt -p 1 "$file" 2>/dev/null | sed '3q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//' | sed 's/ \+/ /g' | sed 's/://g' | sed 's/\*//g'`
          name=`pdf2txt -p 1 "$file" | grep 'CHAPTER' -A3 | sed '4q;d' | sed -e 's/^[ \t]*//' | sed 's/[ \t]*$//' | sed 's/ \+/ /g' | sed 's/://g' | sed 's/\*//g'`
  echo "$file => $newname"
  echo "move \"$file\" \"$newname\"" >> renfile.bat  

But if you’re a Windows user, don’t despair. Enter, A-PDF Preview and Rename, a software that can help you draw boxes around text that contains the name of the pdf that you would like, and recognizes it by OCR, and can even use the similiar location to rename multiple files simultaneously. Get it from here.

The steps to do this are included as screenshots below:
Step1: Draw the files into A-PDF Preview and Rename app:

Step 2: Click on a file, and select option “Select text and OCR”. Drag a box with the mouse around the text you want to select.

Step 3. Click on “OCR” option. You will be shown a preview of the new filename. If this is correct, choose the “Batch OCR” option to rename all files. Note that the program is not 100% accurate, and you may still need to manually correct the filenames in some cases. Still, it works great for a lot of files.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.