I'm a newcomer to the DOS prompt and to making batch files, and I'm wondering if there are any particularly good things I can do with it in this day and age of GUIs. The only really useful one I've made so far forces DEL into interactive mode, without entering the option yourself. I've found a copy of Conway's Life rendered completely in DOS commands, but that's not quite my style.
Any recommendation?
Make a tool that prefixes files in a folder with something, or suffixes, or changes something.
>prefixes files in a folder with something
ren [drive:][path]. prefix*.*
if that's actually made a batch file, then:
ren [drive:][path]%1 %2%1
Where %1 and %2 are arguments passed to the batch file.
I decided to write that "guess a number between 1 and 100" game in a batch file. It's fun, and I'm figuring out how to use set like scanf.
Why batch files?
Why the DOS prompt? There are much better shells available for Windows, like PowerShell.
>>5-6
Do you also ask people why they might want to rewrite Zork in Befunge?
Batch files are a challenge, because it's so hard to do anything useful with them.
Rush is a pretty kickass shell.
Batch files because most of the computers I'm around are Windows, and 100% of those computers have either cmd.exe or command.com.
Believe me, if I had the choice, I'd just install Python interpreters everywhere.
A friend of mine once made a porn game with batch files (circa 1994).
It was hilarious.
one thing i've often wondered is if batch can pipe stdout to stdin of other processes or even to various file descriptors
you know, like > and | in most posix shells
i've never used windows enough to try and find out, can someone answer me this?
Of course it can.
You can't give a FD by number but you can redirect to NUL (/dev/null), CON (screen and keyboard, depending on what direction), printers, etc.
>>12
What if I have a file in the current directory named NUL?
>>13
Funny things happen. Same goes for PRN, CON and any other magic files under DOS.
For real fun, get your hands on a Win9x box and type CD CON\CON
.
>>15
You actually don't really want to do that.
That never worked for me anyway.
>>17
It always did some neat stuff for me. What were you doing wrong?
OP again, is there any command line program Windows comes with by default, allowing me to browse the web via console? Something like Lynx? Or maybe some way to get FTP.exe to make HTTP requests?
telnet <somehost> 80
GET /some/path/ HTTP/1.1
Host: <somehost>
And two enters.
Yes, apparently that is doing something wrong these days. Real hardcore users stay on the earliest version of Windows which still runs on their hardware, even if a more recent one runs faster or fixes bugs.
Microsoft's removed some commands from later versions of CMD.EXE, especially with the NT kernel. For example, SELECT was dropped, which isn't so bad because you can emulate it with SET.
Did I say SELECT? I meant CHOICE.
>>24
Please elaborate, I have some scripts that need this functionality...
SET /P variable=[PromptString] The /P switch allows you to set a variable equal to a line of input entered by the user.
The PromptString is displayed before the user input is read. The PromptString can be empty.
To place the first line of a file into a variable:
Set /P _MyVar=<MyFilename.txt