#usr/bin/perl use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; $articleDirName = "c:\\work\\test\\psq\\test\\"; unless (opendir(DIR, $articleDirName)) { warn "Can't open $articleDirName\n"; closedir(DIR); exit(1); } foreach (readdir(DIR)) { next if $_ eq '.' || $_ eq '..'; $path = "$articleDirName$_"; if (-f $path){ if ($path =~ /\.fin/i){ $doc = Win32::OLE->GetObject($path); $fileName = $path . ".rtf"; print "$fileName\n"; $doc->ActiveDocument->SaveAs({FileName => $fileName, FileFormat => wdFormatRTF}) } undef $doc; undef $path; undef $fileName; } }