ironpaw has asked for the wisdom of the Perl Monks concerning the following question:

Morning Monks I am trying to edit properties of office docs. Perl can use MS's dsofile addons to read and edit this. I can read them and have been trying to change em but no avail. The following is a we script to do this. BTW dsofile stuff is available from (http://sup­port.micro­soft.com/d­efault.asp­x?scid=kb;­EN-US;q224­351) if your interested. I think the setting section of my script might have a simple error I'm a little new. Any ideas from the monistry? Any help at this stage appreciated (this code modified from http://perlmonks.thepen.com/215118.html) I was hell happy to see it but it also don't quite work. (remember you need dsofile.exe first to do this).
use Win32::OLE; use File::Spec; my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader', 'Quit +'); my $directory = "c:\\temp"; opendir(DNAME, $directory) || die "Unable to open the requested direct +ory: $directory\n"; while( my $filename = readdir( DNAME ) ) { next if ($filename eq '.' or $filename eq '..'); my $fullfilename = File::Spec->catdir($directory,$filename); my $properties = $PropertyReader->GetDocumentProperties($fullfilename) + || die("Unable read file properties for '$fullfilename' ", Win32::OL +E->LastError()); if (0 == 0) #ok i was playing # if ( !$properties->{title} || length($properties->{title}) == 0) { $properties->SetProperty('title', "this one"; #why does this not work? +?? print $properties->title; } else { print "File '$filename' --- Title property is set to '" . $properties- +>{title} ."'\n"; } } closedir(DNAME);

Edited by boo_radley : closed code tag, removed breaks

Replies are listed 'Best First'.
Re: Change doc properties
by poj (Abbot) on Jan 15, 2003 at 21:29 UTC
    $properties->SetProperty('title', "this one"; #why does this not work?
    answer
    $properties->SetProperty('title', "this one"); # ) was missing
    poj