使用write.exe自动将旧.wri文件转换为.txt?

时间:2014-01-09 15:44:29

标签: windows batch-file command-line legacy

我必须转换很多旧的Windows WRI文件。我得到了旧的Wordpad - write.exe,它运行在XP或更旧的WIN上。 我找不到有关write.exe的可用命令行选项的任何信息 看来只有选项是:打开由第一个参数传递的文件或通过附加/ p参数打印文件。

我需要的是:自动化(BATCH脚本)打开WRI文件并使用write.exe保存为TXT文件

3 个答案:

答案 0 :(得分:0)

查看可以自动化GUI程序的AutoIt论坛。

答案 1 :(得分:0)

安装打印机:“* local printe * r” - “使用现有的” - “文件:” 作为打印机驱动程序,使用“Generic ” - “ Generic / Text only ”。 然后,您可以将文档“打印”到文件中:

for %%i in (*.wri) do write /p %%i

答案 2 :(得分:0)

创建AutoIt脚本:

#include <File.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>

; http://www.autoitscript.com/site/autoit/downloads/

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

Local $sWriteExePath = @WorkingDir & "\write.exe"
If Not FileExists($sWriteExePath) Then
   $sWriteExePath = FileOpenDialog("Select the write.exe path", "c:\", "Write (write.exe)", $FD_FILEMUSTEXIST)
   If @error Then
      MsgBox($MB_SYSTEMMODAL, "", "No write.exe path was selected!")
      Exit
   EndIf
EndIf

Local $sFilePath = FileSelectFolder("Select the WRI files directory", "c:\")
If @error Then
  MsgBox($MB_SYSTEMMODAL, "", "No folder was selected!")
  Exit
EndIf

Local $aFileList = _FileListToArray($sFilePath, "*.wri", 1)
If @error = 1 Then
  MsgBox($MB_SYSTEMMODAL, "", "Path was invalid!")
  Exit
EndIf
If @error = 4 Then
  MsgBox($MB_SYSTEMMODAL, "", "No files were found!")
  Exit
EndIf

For $i = 1 To $aFileList[0]
   Call("WriToTxt", $sWriteExePath, $sFilePath, $aFileList[$i])
Next

Func WriToTxt($writeExe, $dir, $fileName)
   Local $pathFrom = $dir & '\' & $fileName
   Local $pathTo = StringReplace($pathFrom, ".wri", ".txt", 1)
   Local $winName = "Write - " & StringReplace($fileName, ".wri", '')

   If Not FileExists($pathTo) Then
      Run($writeExe & ' ' & $pathFrom)
      WinWaitActive($winName)
      Send("!fa")
      WinWaitActive("Save As")
      Send($pathTo)
      ControlSend("Save As", "", "[CLASS:ComboBox; INSTANCE:1]", "Text Files (*.TXT)")
      Sleep(1)
      ControlClick("Save As", "", "[CLASS:Button; TEXT:OK]")
      WinWaitActive("Write", "Do you want to save?", 2)
      If WinActive("Write", "Do you want to save?") Then
         Send("!y")
      EndIf
      WinClose($winName)
   EndIf
EndFunc