#!/usr/bin/env perl # # Copyright (c) 2007, Gregory Fleischer (gfleischer@gmail.com) # License: Revised BSD # # author-info.pl - retrieve document information from Word document # # uses Harlan Carvey's MSWord package # see http://windowsir.blogspot.com/2006/09/metadata-and-ediscovery.html # use File::MSWord; use strict; my $file = shift() or die "missing file"; if (! -f $file) { die "file [$file] doesn't exist"; } my $doc = File::MSWord::new($file); my @savedBy = $doc->getSavedBy(); my $buf = $doc->readStreamTable($savedBy[0],$savedBy[1]); my %revisions = $doc->parseSTTBF($buf, "author", "path"); print "---=== Author(s) Information ===---\n"; foreach my $k (sort { $a <=> $b } keys(%revisions)) { my $author = $revisions{$k}{"author"}; if ($author=~/^\s*$/) { $author = "(unknown)"; } my $path = $revisions{$k}{"path"}; if ($path=~/^\s*$/) { $path = "(no path)"; } printf("%d. %s : %s\n", $k, $author, $path); } exit 0; # eof