Possible to convert M$ Word Doc into .TXT?
Moderator: DosItHelp
Possible to convert M$ Word Doc into .TXT?
Hi!
I have a many different folders that contains alot of Microsoft Word 97 - 2003 Documents.
I want to go into a folder and execute a .bat which convert these into a new folder within the current folder with .txt as output.
Is this possible?
I have a many different folders that contains alot of Microsoft Word 97 - 2003 Documents.
I want to go into a folder and execute a .bat which convert these into a new folder within the current folder with .txt as output.
Is this possible?
Re: Possible to convert M$ Word Doc into .TXT?
VBS might have the ability to interact with Word but failing that an AutoIt script could press the buttons to do it, I think.
Re: Possible to convert M$ Word Doc into .TXT?
hi,
in case if microsoft office is not available in the pc to convert than can use below
there is one software that we were using for a very long time for comparison purpose
the main page is in japanese but google nearly translate the correct word.
http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html
translate
can be used from win95 to the latest version. really fast. it can convert the ofice excel/word/powerpoint and other format to txt. small file size but huge support for different formats.
in case if microsoft office is not available in the pc to convert than can use below
there is one software that we were using for a very long time for comparison purpose
the main page is in japanese but google nearly translate the correct word.
http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html
translate
Code: Select all
http://translate.google.com/translate?hl=en&sl=ja&u=http://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html&prev=/search%3Fq%3Dhttp://www31.ocn.ne.jp/~h_ishida/xdoc2txt.html%26client%3Dfirefox-a%26hs%3D1zV%26rls%3Dorg.mozilla:en-US:official
can be used from win95 to the latest version. really fast. it can convert the ofice excel/word/powerpoint and other format to txt. small file size but huge support for different formats.
Re: Possible to convert M$ Word Doc into .TXT?
Yes , you can .But you'll have to use jscript, vbscript or powershell. Here's how you can open document->
http://msdn.microsoft.com/en-us/library ... =office.11).aspx
here are save constants
http://msdn.microsoft.com/en-us/library ... 39952.aspx
If have a time I 'll create a script tomorrow
http://msdn.microsoft.com/en-us/library ... =office.11).aspx
here are save constants
http://msdn.microsoft.com/en-us/library ... 39952.aspx
If have a time I 'll create a script tomorrow
Re: Possible to convert M$ Word Doc into .TXT?
This is a hybrid bat/vbscript and need to be saved as .bat:
To start not visible word application and copying to %windir%\System32\ requires admin privileges , so you'll have to run this as administrator.
Code: Select all
'>nul 2>&1|| @copy /Y %windir%\System32\doskey.exe %windir%\System32\'.exe >nul
'&&@echo off && cls &&goto :end_vbs
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = FALSE
'Open doc for reading
Set WordDoc = WordApp.Documents.Open(WScript.Arguments.Item(0),true)
'wdFormatText 2
'wdFormatUnicodeText 7
format = CInt(WScript.Arguments.Item(2) )
WordDoc.SaveAs WScript.Arguments.Item(1) ,format
WordDoc.Close()
WScript.Quit
:end_vbs
'& if "%~1" equ "-help" echo %~n0 word_document [ destination [-unuicode] ]
'& if "%~1" equ "" echo word document not given & exit /b 1
'& if not exist "%~f1" echo word document does not exist & exit /b 2
'& if "%~2" equ "" ( set "save_as=%~n1.txt") else ( set "save_as=%~2")
'& if exist "%~f2" del /s /q "%~f2"
'& if "%~3" equ "-unuicode" ( set "format=7") else ( set "format=2")
'& taskkill /im winword* /f >nul 2>&1
'& cscript /nologo /E:vbscript %~f0 "%~f1" "%save_as%" %format%
'& pause
'& rem del /q %windir%\System32\'.exe
To start not visible word application and copying to %windir%\System32\ requires admin privileges , so you'll have to run this as administrator.
Last edited by npocmaka_ on 19 Jul 2013 16:35, edited 2 times in total.
Re: Possible to convert M$ Word Doc into .TXT?
That's an interesting use of doskey. 

Re: Possible to convert M$ Word Doc into .TXT?
foxidrive wrote:That's an interesting use of doskey.
Subst.exe (and a bunch of exes in system32 that I don't know what in fact are doing) also can be used but I prefer doskey because I know that will do anything in a batch file and is fast enough.
Re: Possible to convert M$ Word Doc into .TXT?
I saw that and am totally confused.foxidrive wrote:That's an interesting use of doskey.

Re: Possible to convert M$ Word Doc into .TXT?
Samir wrote:I saw that and am totally confused.



Do not hesitate and ask.I'll be glad to explain.
Re: Possible to convert M$ Word Doc into .TXT?
I'll drop a hint...
This command line generates an error message.
Note that every line in the batch code section starts with '&
This command line generates an error message.
Code: Select all
d:\abc>'& rem
''' is not recognized as an internal or external command,
operable program or batch file.
Note that every line in the batch code section starts with '&
Re: Possible to convert M$ Word Doc into .TXT?
So I kinda follow the vbscript, but don't know why you copy doskey and delete it at the end.npocmaka_ wrote:Samir wrote:I saw that and am totally confused.
![]()
![]()
![]()
Do not hesitate and ask.I'll be glad to explain.
Re: Possible to convert M$ Word Doc into .TXT?
In fact the deleting is commented but could be uncommented.
I'm copying to doskey to '.exe somewhere in the %PATH% so after that it can be called as '&.
In vbscript this is a comment , but for the batch means execute '.exe and then the next command.
As doskey does do nothing in bat file (especially without parameters) and is fast enough in fact this will mean - do nothing and then execute the next command.
I'm copying to doskey to '.exe somewhere in the %PATH% so after that it can be called as '&.
In vbscript this is a comment , but for the batch means execute '.exe and then the next command.
As doskey does do nothing in bat file (especially without parameters) and is fast enough in fact this will mean - do nothing and then execute the next command.
Re: Possible to convert M$ Word Doc into .TXT?
WOW. I'm totally in awe. I've been a batch file junkie since the days of DOS 3.3, and I never knew about the '&. I tested it out on the command line usingnpocmaka_ wrote:In fact the deleting is commented but could be uncommented.
I'm copying to doskey to '.exe somewhere in the %PATH% so after that it can be called as '&.
In vbscript this is a comment , but for the batch means execute '.exe and then the next command.
As doskey does do nothing in bat file (especially without parameters) and is fast enough in fact this will mean - do nothing and then execute the next command.
Code: Select all
echo '& tezt
Code: Select all
'& tezt
Code: Select all
'
'tezt' is not recognized as an internal or external command,
operable program or batch file.
Re: Possible to convert M$ Word Doc into .TXT?
It's not `& as a term.
` is the new command you created by copying doskey.exe and & is the command separator since Windows NT was introduced.
` is the new command you created by copying doskey.exe and & is the command separator since Windows NT was introduced.
Re: Possible to convert M$ Word Doc into .TXT?
Ahh, that makes a bit more sense. I remember using && in if, but didn't realize it was more than that after NT. Good stuff.foxidrive wrote:It's not `& as a term.
` is the new command you created by copying doskey.exe and & is the command separator since Windows NT was introduced.
