Solved

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

Posted on 2014-07-23
8
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:Zoppo
ID: 40214257
Could you post such a file with those  [] [] [] []  here?
0
 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
clicking to find my folders on wamp 8 47
Hide file extensions in Notepad++ tabs 2 84
EditableGrid how to fetch rows from MySql in php 14 73
"lblTime is not declared" 3 65
Creating and Managing Databases with phpMyAdmin in cPanel.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install

739 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