batch to change .bat to cmd or .exe

i was just wondering how could i make a batch file to convert .bat to .cmd (or .exe if possible)
i tryed wtih this but it didnt work

@echo off
ren %1 *.cmd

im just a beginer atm, just learning from examples

sort by: active | newest | oldest
rich_moe7 years ago was what I used, but I was never good at text/scripting.

With the concentration on scripting languages these days, I'm not sure how much these programs will get used anymore. As a learning tool, my guess is that this may be useful, but the ability to look inside an .exe file after it has been converted is zero to none.
Was it bat2exe or bat2com. I'll have to go dig out the Win98 machine. It's on there somewhere. 

You will need a converter like one of these. Just renaming a .BAT to .COM or .EXE won't work at all. Of course you could write a batch file to use one of these command line (DOS) programs to automate the process. Just use %1.bat and %1.exe (or com, depending on the program) for the names.

NachoMahma7 years ago
.  Batch files are text-based scripts.
.  Applications are binary/executable files.
.  You can't change one to the other just by changing the file extension.
.  As lemonie mentioned, there are programs that will compile a batch script into an executable file. Google is your friend.
I disagree with "compile" - I think differently as that comment. But I don't know too much. My main justification for self-extracting-archive is an Instructable that tells you how to get the bat out of one of these .exes, involving running it. Which I can't find...

.  But there's nearly always more than one way to skin a cat. ;)
It depends whether you read "compile" as - translate script to equivalent x86 executable code, by use of a software compiler. Or take it in a broad sense to mean "convert to a different file type"

.  I've never seen it used in your broader sense, only the text-code-to-binary.
It's not my broader sense, and that was my point. I don't believe anyone would create a compiler to convert batch script to x86machine code. I expect the thing is just packaged into a self-extracting archive, like software installation packages.
What do you think?

.  The last one I used (that was 20+ years ago and I don't recall the name) compiled the DOS commands into CALLs, GOSUBs, POKEs, &c in binary ("x86machine code") - just like the DOS interpreter does on the fly. I supposed you could call that pre-interpreted instead of complied.
.  And I'm not saying that your method isn't (wasn't) used somewhere, just that I haven't seen it.
lemonie7 years ago
You can get software that will package a .bat into an .exe, I'm guessing it works like a self-extracting archive.
As I can't recommend one, just search for "bat to exe converter"