Ello all. I am trying to change the properties on some documents. I have the following code which reads the properties fine but does not change them. Any ideas?
Any pointers appreciated
BTW you need dsofile.exe from MS to use this avail from:
# use strict;
use Win32::OLE;
use File::Spec;
my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader', 'Quit');
my $directory = "c:\\temp\\cst";
opendir(DNAME, $directory) || die "Unable to open the requested directory: $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::OLE->LastError());
if (0 == 0)
# if ( !$properties->{title} || length($properties->{title}) == 0)
{
print "File '$filename' --- Title not set setting to '$filename'\n";
$properties->SetProperty('title', "this"
;
$properties->SetProperty('author', "this"
;
$properties->SetProperty('comments', "this"
;
$properties->SetProperty('company', "this"
;
print "me File '$filename' --- Title property is set to '" . $properties->{title} ."'\n";
print $properties->author;
print $properties->title;
print $properties->comments;
print $properties->datecreated;
print $properties->company;
} else {
print "File '$filename' --- Title property is set to '" . $properties->{title} ."'\n";
}}
closedir(DNAME);
Any pointers appreciated
BTW you need dsofile.exe from MS to use this avail from:
# use strict;
use Win32::OLE;
use File::Spec;
my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader', 'Quit');
my $directory = "c:\\temp\\cst";
opendir(DNAME, $directory) || die "Unable to open the requested directory: $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::OLE->LastError());
if (0 == 0)
# if ( !$properties->{title} || length($properties->{title}) == 0)
{
print "File '$filename' --- Title not set setting to '$filename'\n";
$properties->SetProperty('title', "this"
$properties->SetProperty('author', "this"
$properties->SetProperty('comments', "this"
$properties->SetProperty('company', "this"
print "me File '$filename' --- Title property is set to '" . $properties->{title} ."'\n";
print $properties->author;
print $properties->title;
print $properties->comments;
print $properties->datecreated;
print $properties->company;
} else {
print "File '$filename' --- Title property is set to '" . $properties->{title} ."'\n";
}}
closedir(DNAME);