Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently recovered many deleted files by using a tool called photorec -

Great life saver. Only problem is that recovered files have their names replaced by some random string that this program generates. (File name and directory structures were lost due to user deletion of the files).

So I ran another program called photorecsorter to sort recovered files into folders by their file extensions (pdf in one folder, ppt in another and so on)

I recovered around 100K+ files so I can't ask user to open files and look at the content to find what they're looking for. I know in word document file metadata (headers) can help me to retrieve two key elements of information which can be then used to rename that file - Title of the word document and last date modified. Once I know how to this for word doc, maybe I can do it for other office extensions and pdf on my own. I looked for some tools online but before I try something - I wanted to see what experts may suggest here.


share|improve this question

A VBS (VBScript) file like the following should help for Word documents at least:

Option Explicit

Dim objWord, objDoc

Set objWord = CreateObject("Word.Application")
objWord.Visible = False
objWord.DisplayAlerts = False
objWord.Documents.Open "C:\MyDoc.docx", False, True ' path, confirmconversions, readonly
Set objDoc = objWord.ActiveDocument

MsgBox "Title: """ & objDoc.BuiltInDocumentProperties("Title") & """"
MsgBox "Subject: """ & objDoc.BuiltInDocumentProperties("Subject") & """"
MsgBox "Author: """ & objDoc.BuiltInDocumentProperties("Author") & """"
MsgBox "Creation Date: """ & objDoc.BuiltInDocumentProperties("Creation Date") & """"
MsgBox "Last Save Time: """ & objDoc.BuiltInDocumentProperties("Last Save Time") & """"

objWord.Quit 0 ' wdDoNotSaveChanges
Set objWord = Nothing
Set objDoc = Nothing

You can use FileSystemObject to iterate through all the DOC/DOCX files in a directory, and rename them based on the property strings returned.

For Excel or PowerPoint files, use Excel.Application or PowerPoint.Application when you create the document objects. If you get stuck just search the net for relevant Office automation VBScript tutorials.

There's no general method to retrieve metadata for all file formats obviously, so other formats such as PDF will require an entirely different solution. I recommend you search the net or post a new question if you need help with it.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .