Useful batch files? (27)

1 Name: #!/usr/bin/anonymous : 2008-02-26 15:43 ID:VUe6csWH

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?

2 Name: #!/usr/bin/anonymous : 2008-02-26 17:22 ID:Heaven

Make a tool that prefixes files in a folder with something, or suffixes, or changes something.

3 Name: #!/usr/bin/anonymous : 2008-02-26 18:01 ID:VUe6csWH

>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.

4 Name: #!/usr/bin/anonymous : 2008-02-27 18:56 ID:VUe6csWH

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.

5 Name: #!/usr/bin/anonymous : 2008-02-27 22:07 ID:RXz9bhrd

Why batch files?

6 Name: #!/usr/bin/anonymous : 2008-02-28 05:58 ID:rVaF4VdH

Why the DOS prompt? There are much better shells available for Windows, like PowerShell.

7 Name: #!/usr/bin/anonymous : 2008-02-28 11:01 ID:Heaven

>>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.

8 Name: #!/usr/bin/anonymous : 2008-02-28 12:47 ID:Heaven

Rush is a pretty kickass shell.

9 Name: #!/usr/bin/anonymous : 2008-02-28 13:24 ID:VUe6csWH

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.

10 Name: dmpk2k!hinhT6kz2E : 2008-02-28 20:52 ID:Heaven

A friend of mine once made a porn game with batch files (circa 1994).

It was hilarious.

11 Name: #!/usr/bin/anonymous : 2008-02-29 07:39 ID:axaHgbwD

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?

12 Name: #!/usr/bin/anonymous : 2008-02-29 10:17 ID:Heaven

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.

13 Name: #!/usr/bin/anonymous : 2008-02-29 12:27 ID:Heaven

>>12
What if I have a file in the current directory named NUL?

14 Name: #!/usr/bin/anonymous : 2008-02-29 12:49 ID:Heaven

>>13
Funny things happen. Same goes for PRN, CON and any other magic files under DOS.

15 Name: #!/usr/bin/anonymous : 2008-03-01 00:38 ID:Heaven

For real fun, get your hands on a Win9x box and type CD CON\CON.

16 Name: #!/usr/bin/anonymous : 2008-03-01 10:49 ID:Heaven

>>15
You actually don't really want to do that.

17 Name: #!/usr/bin/anonymous : 2008-03-01 12:04 ID:Heaven

That never worked for me anyway.

18 Name: #!/usr/bin/anonymous : 2008-03-01 13:39 ID:Heaven

>>17
It always did some neat stuff for me. What were you doing wrong?

19 Name: #!/usr/bin/anonymous : 2008-03-13 02:39 ID:QKVXTVoB

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?

20 Name: dmpk2k!hinhT6kz2E : 2008-03-13 02:55 ID:Heaven

telnet <somehost> 80
GET /some/path/ HTTP/1.1
Host: <somehost>

And two enters.

21 Name: #!/usr/bin/anonymous : 2008-03-13 21:11 ID:w6XyB6B/

>>18
He updated his system.

22 Name: #!/usr/bin/anonymous : 2008-03-14 14:22 ID:Heaven

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.

23 Name: #!/usr/bin/anonymous : 2008-03-15 15:37 ID:VUe6csWH

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.

24 Name: #!/usr/bin/anonymous : 2008-03-15 15:40 ID:VUe6csWH

Did I say SELECT? I meant CHOICE.

25 Name: /dev/null/ : 2008-03-20 01:18 ID:5WpW16XA

>>24
Please elaborate, I have some scripts that need this functionality...

26 Name: >>25 : 2008-03-21 11:34 ID:Heaven

/dev/null is not a directory.

27 Name: #!/usr/bin/anonymous : 2008-03-22 13:00 ID:VUe6csWH

>>25

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

This thread has been closed. You cannot post in this thread any longer.