Solved

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

Posted on 2014-07-23
8
368 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 31

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:Montoya
Montoya 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 31

Expert Comment

by:Zoppo
ID: 40214257
Could you post such a file with those  [] [] [] []  here?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 31

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

867 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

23 Experts available now in Live!

Get 1:1 Help Now