#!/usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell # # MkWinwordIndex # # Creates a HTML index for MS Office documents # # (C) 1997 by Bernard Weiler # # Config: # # Directory where "lhalw" and "ldat" is stored: my $Bin="/usr/local/bin/"; # Name of generated index file: my $MkWinwordIndex="MkWinwordIndex.html"; # -------------------- # Name: Bernard Weiler # Org.: OeN TR HW A, Mch-H, Siemens AG # Tel: office 722-28374, private 089-7901737 # email: pmp@egnetz.uebemc.siemens.de # or Bernard.Weiler@oen.siemens.de # Snailmail: Siemens AG, OeN TR HW A, Mch-H, Postfach 700071, D-81359 # Munich # Intranet: http://susi.oen.siemens.de/~pmp # PGP: the public key may be downloaded from # http://trust.sbs.de/html/med.htm # or from pgp-public-keys@uni-paderborn.de # # --------------36C25AB72FCE use strict; use 5.004; my ($File,$is); my $Dir=shift; if((not defined $Dir)or($Dir =~/-h/i)){ print " $0 - Directory Listing of Microsoft office Files Usage: $0 $0 [-h|-H|-help] Purpose: generates in a file $MkWinwordIndex containing metainformations of all Microsoft office files in . It supports recursive index-trees. Example: find . -type d $0 '{}' \; Author: B.Weiler, TR HW A, 8.12.97 "; exit; } open(INDEX,">$Dir/$MkWinwordIndex") or die; my @MetaList=qw(Filename Title Authress Application Created); my %Meta; push(@MetaList,"Last saved"); push(@MetaList,"MetaInfos"); push(@MetaList,"DocumentContent"); chomp $Dir; print INDEX"

Directory Listing of Microsoft office Files

\n"; print INDEX"Directory: $Dir

\b"; print INDEX""; foreach $is (@MetaList){print INDEX"\n"} print INDEX"\n"; opendir(DH,$Dir); foreach $File (readdir(DH)){ next if($File=~/^\./); next if($File eq $MkWinwordIndex); if($File=~/\.(doc|xls|ppt)$/i){ #print INDEX STDERR "\n"; print INDEX ""; my @il; foreach $is (@MetaList){$Meta{$is}='-'} $Meta{Filename}="$File"; open(PIPE,"$Bin/ldat '$Dir/$File' |"); while(){ chomp; foreach $is (@MetaList){ next unless($_=~$is); $Meta{$is}=$_; $Meta{$is}=~s|^.*?:||; } push(@il,$_); $Meta{Filename}.="
Error found in Document!" if(/Error/); } close PIPE; $Meta{MetaInfos}="
".join('
',@il)."
"; if($File=~/\.doc/){ $Meta{"DocumentContent"}="
";
      my $ii=0;
      my $is='';
      open(PIPE,"$Bin/lhalw -FN -c 50 '$Dir/$File' |");
      while(){
        chomp;
	last if($ii==10);
	$ii++;
	$Meta{"DocumentContent"}.="$_ (...truncated)\n";
      }
      close(PIPE);
      $Meta{"DocumentContent"}.="\n(...truncated)
"; } foreach $is (@MetaList){print INDEX"
\n"} print INDEX"\n"; } else{ foreach $is (@MetaList){$Meta{$is}='-'} if(-d $File){ $Meta{Filename}="$File"; $Meta{Application}="Is a directory"; } else{ $Meta{Filename}="$File"; $Meta{Application}="not a MS-office application"; } print INDEX ""; foreach $is (@MetaList){print INDEX"\n"} print INDEX"\n"; } } closedir(DH); print INDEX"
$is
$Dir/$File
$Meta{$is}
$Meta{$is}
"; print INDEX"Generated by $0\n"; close INDEX;