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

In reply to Change doc properties by ironpaw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.