DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: rename pdf, word, etc files based on their text content  (Read 25,638 times)

kalos

  • Member
  • Joined in 2006
  • **
  • Posts: 1,824
rename pdf, word, etc files based on their text content
« on: December 09, 2011, 08:45 AM »
hello

is there any tool that will rename files like pdf, word, etc based on their content text?

ie, if a specific match of a regex exists in the content of a pdf file, then rename the file with that match

thanks!

kalos

  • Member
  • Joined in 2006
  • **
  • Posts: 1,824
Re: rename pdf, word, etc files based on their text content
« Reply #1 on: December 10, 2011, 03:22 PM »
there isnt really such thing?
it would be so convenient!

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: rename pdf, word, etc files based on their text content
« Reply #2 on: December 10, 2011, 03:27 PM »
skwire is still busy I guess ;D ;D
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: rename pdf, word, etc files based on their text content
« Reply #3 on: December 10, 2011, 03:37 PM »
Quote
is there any tool that will rename files like pdf, word, etc based on their content text?

i have often thought that a commandline utility that could take a pdf file, grab its title, author, and date and rename it to some combination of those, would be EXTREMELY useful.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: rename pdf, word, etc files based on their text content
« Reply #4 on: December 10, 2011, 03:40 PM »
I'd be going nuts trying to find that file I stored and it got renamed to something totally different :huh:
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

yksyks

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 476
Re: rename pdf, word, etc files based on their text content
« Reply #5 on: December 10, 2011, 03:51 PM »
Peter's Flexible Renaming Kit (PFrank) has a plugin for inserting title metadata from PDF files. Haven't tried by myself, though.

kalos

  • Member
  • Joined in 2006
  • **
  • Posts: 1,824
Re: rename pdf, word, etc files based on their text content
« Reply #6 on: December 10, 2011, 04:09 PM »
Peter's Flexible Renaming Kit (PFrank) has a plugin for inserting title metadata from PDF files. Haven't tried by myself, though.

but pdf metadata does not contain pdf text content, only author, creation date, etc, AFAIK

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: rename pdf, word, etc files based on their text content
« Reply #7 on: December 10, 2011, 04:15 PM »
skwire is still busy I guess ;D ;D

Based on my own experience working with PDF files in this manner, it's a huge pain in the arse.  Kalos, have you ever taken a look at Calibre to help manage your PDF collection?  I use it to convert stuff to read on my Android phone.

http://calibre-ebook.com/

yksyks

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 476
Re: rename pdf, word, etc files based on their text content
« Reply #8 on: December 10, 2011, 06:24 PM »
but pdf metadata does not contain pdf text content, only author, creation date, etc, AFAIK
You're right, I was thinking more about mouser's request.

sbertolucci

  • Participant
  • Joined in 2006
  • *
  • Posts: 1
Re: rename pdf, word, etc files based on their text content
« Reply #9 on: December 11, 2011, 01:21 PM »
Quote
is there any tool that will rename files like pdf, word, etc based on their content text?

i have often thought that a commandline utility that could take a pdf file, grab its title, author, and date and rename it to some combination of those, would be EXTREMELY useful.

In the past I've written a little command line tool which sets the date of a PDF file to the one recorded in its metadata and it was a difficult task because there's not a standard. Every program which generates a PDF writes that data in it's own way

IainB

  • @Slartibartfarst
  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,544
Re: rename pdf, word, etc files based on their text content
« Reply #10 on: December 11, 2011, 02:16 PM »
is there any tool that will rename files like pdf, word, etc based on their content text?
ie, if a specific match of a regex exists in the content of a pdf file, then rename the file with that match
Without knowing more of what lies behind your request, it may be difficult to see how to help.

I think you might be able to get this done in some shape or form by using a reference management system that can handle PDF files. From that perspective, I would suggest that Qiqqa might be worth a look. I haven't played with the latest version, so I can' t really say any more about it.
Qiqqa  could maybe even be modified to provide a feature that you have asked the author to put in, if it wasn't there already.
Also, you might find that the capabilities of something like Qiqqa enabled you to discover a new/changed requirement to this current requirement.
Adobe may have something to help here too, of course.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 3,217
Re: rename pdf, word, etc files based on their text content
« Reply #11 on: December 11, 2011, 07:44 PM »
a commandline utility that could take a pdf file, grab its title, author, and date and rename it to some combination of those, would be EXTREMELY useful.

@mouser: closest I know of to that would be pdfinfo from the XPDF package.

pdfinfo Help:
pdfinfo version 3.02
 Copyright 1996-2007 Glyph & Cog, LLC
 Usage: pdfinfo [options] <PDF-file>
   -f <int>       : first page to convert
   -l <int>       : last page to convert
   -box           : print the page bounding boxes
   -meta          : print the document metadata (XML)
   -enc <string>  : output text encoding name
   -opw <string>  : owner password (for encrypted files)
   -upw <string>  : user password (for encrypted files)
   -cfg <string>  : configuration file to use in place of .xpdfrc
   -v             : print copyright and version info
   -h             : print usage information
   -help          : print usage information
   --help         : print usage information
   -?             : print usage information

The command line
pdfinfo 2011_velbon_catalog.pdf > info.txt
on the Velbon (tripod) catalogue gives:

Title:          2011_catalog.indd
Creator:        Adobe InDesign CS3_J (5.0.4)
Producer:       Adobe PDF Library 8.0
CreationDate:   03/17/11 17:31:25
ModDate:        03/24/11 11:30:11
Tagged:         no
Pages:          16
Encrypted:      yes (print:yes copy:yes change:no addNotes:no)
Page size:      1274.43 x 273.584 pts
File size:      9668147 bytes
Optimized:      yes
PDF version:    1.6

I used to use this for re-naming PDFs of patents at work, with something like an AWK script to extract the relevant information and write a temporary batch file that did the work.  The trouble is you can't rely on all those fields being filled in for any particular PDF.

Original address: https://www.donationcoder.com/forum/index.php?topic=29207.0