Running SAVE AS using a batch file - batch-file

I have a batch file that creates text files in multiple folders.
What I need it to do as well, is after creating that text file, save a copy of it as a .scr file
If I were to do with this without a batch file, I would open the text file, click SAVE AS and save the file with a .scr extension. I cannot figure out how to add this feature to my batch file however.
The original text file cannot be erased, so I can't just change the extension. I would have to copy it, then change the extension, or imitate the SAVE AS feature.
Help?

I just used the ren *<> *<> command. It is extremely redundant because I end up making two text files that are identical and just changing one, but it gets the job done

Related

Batch copy character

So, I'm trying to make a folder with a load of batch files, each individually will copy a certain character to the clipboard. My first one was ñ. I made a batch file that runs the script
echo|set/p=ñ|clip
But on running the batch file ├▒ <- is copied to my clipboard.
Anyone know why and what I should change in the script?
Turns out I needed to change the batch file to use UTF-8 by putting
chcp 65001
at the start of the batch file.

How do I copy existing files and create a duplicate files using xcopy?

I can't seem to find a way to copy an existing file but I do not want to let the previous file with the same name get overwritten. Let say I want to copy data.txt from various pc's by using batch file but I do not want "data.txt" gets overwritten, instead is there a way for the command to generate automated filename to avoid it from overwritten?
You can use the "/-y" switch to confirm before copying a duplicate file.
/-y : Prompts to confirm that you want to overwrite an existing
destination file.
The entire list of switches can be found here

Batch File : could not open specific file with WordPad and save it

Initially I captured a file using batch file and it is open with Notepad. How do I code the batch file so that it will save with WordPad.
Batch File :
Remarks:This document is for Linksys for version v4.30.5, the auto sensing part.
"C:\Program Files (x86)\Wireless Guard\wget" "http://192.168.1.254/xslt#PAGE=C_2_0"
copy "xslt#PAGE=C_2_0" "xslt#PAGE=C_2_0.txt"
del "xslt#PAGE=C_2_0"
You don't really have to do anything to get it to save with WordPad as such. As previously commented batch files output to plain text so you can open it with WordPad if you wish.
You could do this in batch with:
write txtfile.txt
Or to permanently associate WordPad set it as your default txt program in Control Panel.
Hope this helps.

How to append content to an existing log file without overwriting using windows command line?

I have a batch file where I would like to append to the same log file, without overwriting, from two or more build files. I intend to write something like below:
SET logdir=C:\Logs\BuildLogFile.txt
NAnt -buildfile:ServiceProxies.build > %logdir%
SET logdir=C:\Logs\BuildLogFile.txt
NAnt -buildfile:SecurityService.build > %logdir%
But the txt file gets overwritten. Is there any way by which I can append to the same .txt file because I want to use a single Log file for the entire project?
Use >> to append, instead of >.

How to create a batch file from .exe file?

I want to know simply how to create a batch file from .exe file?
If you mean you want to create a new batch file from an unrelated existing executable file (in other words, the batch file does something different), you do it the way you create any file. In C, you'd use fopen, fwrite and fclose to create your new file and write whatever batch file commands you want to it.
If you mean you want to create a batch file that "intercepts" your exe file, you can do that too. If your executable file is pax.exe, you can simply rename it to pax2.exe and create a batch file called pax.cmd thus:
#echo off
pax2.exe
This will allow you to do arbitrary actions before and after your executable runs but there are things to watch out for such as executables that return control before they're actually finsihed.
If, however, you're talking about converting an arbitrary executable into a batch file that performs the same task, that's much more difficult. Unless you have the source code or a very good specification on how the executable works, you're going to have a lot of trouble.
Automating the conversion for anything but the simplest executable will be insanely difficult.
And, if you want a link to a batch file that runs your executable, just create the batch file (say in c:\bin\pax.cmd) containing:
#echo off
c:\bin\pax.exe
and then create a shortcut to it from wherever you want (such as the desktop). You could even put the batch file itself in your desktop directory but I'm not a big fan of that. However, to each their own.

Resources