Link to home
Start Free TrialLog in
Avatar of NNiicckk
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"
SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NNiicckk
NNiicckk

ASKER

The file, for some reason, shows a couple of blank data fields as [] [] [] [] when I use through Monarch.  But if I open and save the .txt file as itself, the squares vanish and the blank (or null) are is represented correctly.
Could you post such a file with those  [] [] [] []  here?
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
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It was the best answer provided.