Solved

Can I save (or save as) an open text file using a batch?

Posted on 2014-07-23
8
364 Views
Last Modified: 2014-07-28
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"
0
Comment
Question by:NNiicckk
  • 4
  • 3
8 Comments
 
LVL 30

Assisted Solution

by:Zoppo
Zoppo earned 250 total points
ID: 40214000
Hi NNiicckk,

why don't you simply copy the file?

ZOPPO
0
 
LVL 19

Assisted Solution

by:Iammontoya
Iammontoya earned 250 total points
ID: 40214007
Use copy command to copy the file and change the destination, therefore name

here's the reference:
Copies one or more files to another location.

COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
     [+ source [/A | /B] [+ ...]] [destination [/A | /B]]

  source       Specifies the file or files to be copied.
  /A           Indicates an ASCII text file.
  /B           Indicates a binary file.
  destination  Specifies the directory and/or filename for the new file(s).
  /V           Verifies that new files are written correctly.
  /N           Uses short filename, if available, when copying a file with a
               non-8dot3 name.
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless COPY command is being executed from
within a batch script.

To append files, specify a single file for destination, but multiple files
for source (using wildcards or file1+file2+file3 format).
0
 

Author Comment

by:NNiicckk
ID: 40214222
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.
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 40214257
Could you post such a file with those  [] [] [] []  here?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:NNiicckk
ID: 40214355
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
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 40214425
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.
0
 

Accepted Solution

by:
NNiicckk earned 0 total points
ID: 40214485
OK, Thanks
0
 

Author Closing Comment

by:NNiicckk
ID: 40223668
It was the best answer provided.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now