NNiicckk
asked on
Can I save (or save as) an open text file using a batch?
I have opened a .txt file using a batch. Now, I would like to save as "new file name.txt".
Example:
I open the text file using %SystemRoot%\explorer.exe "my path\MyAccount.txt"
I would like to save as "AnyFile.txt"
Example:
I open the text file using %SystemRoot%\explorer.exe "my path\MyAccount.txt"
I would like to save as "AnyFile.txt"
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Could you post such a file with those [] [] [] [] here?
ASKER
I cannot send the text file but a small reference. The squares do not appear in the text file but when attempting to convert them in Monarch. Once I save the file as itself, the issue is resolved.
squares.PNG
squares.PNG
Hm - this doesn't help much. I thought with a sample file we could try to find a way to convert the file with some command line tools.
Generally I would say converting it by opening it in a text editor and anyhow make the text editor doing a 'Save As' is diffcult because I think it can only be done via GUI automation. If you really want to try it I'd suggest you take a look at AutoIt (http://www.autoitscript.com/site/autoit/), this is a scripting language with lots of possibilities to control other applications.
Anyway I would suggest to find a way to do it without using a text editor this way because with the text editor there might be problems with GUI automation, i.e. if while the file is open it might be any other application pops up and thus disturbs the automation script.
With such a sample file it would be easy to i.e. write a small VB script which can be called by your batch file, but without knowing what the original file-format is it's hard.
Generally I would say converting it by opening it in a text editor and anyhow make the text editor doing a 'Save As' is diffcult because I think it can only be done via GUI automation. If you really want to try it I'd suggest you take a look at AutoIt (http://www.autoitscript.com/site/autoit/), this is a scripting language with lots of possibilities to control other applications.
Anyway I would suggest to find a way to do it without using a text editor this way because with the text editor there might be problems with GUI automation, i.e. if while the file is open it might be any other application pops up and thus disturbs the automation script.
With such a sample file it would be easy to i.e. write a small VB script which can be called by your batch file, but without knowing what the original file-format is it's hard.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It was the best answer provided.
ASKER