################################# # # SetTitleProp.pl # # A quick and dirty script to set the 'title' property of a Structured Storage file. # The files can be either on an NTFS partition, or could be MS Office documents on # NTFS or FAT. # # To use it you must have installed the dsofile utility from the microsoft site. Currently the # link to it is: # # http://support.microsoft.com/default.aspx?scid=kb;EN-US;q224351 # # But if the url is invalid then search for dsofile.exe, or knowledge article 22435. # # ################################## use strict; use Win32::OLE; use File::Spec; my $PropertyReader = Win32::OLE->new('DSOleFile.PropertyReader', 'Quit'); my $directory = "g:\\fileproptest"; 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 ( !$properties->{title} || length($properties->{title}) == 0) { print "File '$filename' --- Title not set setting to '$filename'\n"; $properties->SetProperty('title', $filename); } else { print "File '$filename' --- Title property is set to '" . $properties->{title} ."'\n"; } } closedir(DNAME);