Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing document properties

Status
Not open for further replies.

ironpawz

IS-IT--Management
Oct 8, 2002
44
NZ
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);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top