Calling all MS-DOS Batch file experts

I realize this question may never get answered here, but it is worth a try…
How do I obtain information from the user in a batch file (not from the command line paramaters, but after a batch file has been run)

I would have the string “Please enter the date (DDMMYY)” and would then want a variable containing whatever was entered for use later on in the batch file.
or (This will solve the problem also, but is probably more complicated) how would I obtain the date one day prior to the system date into a variable?

Thanks

Hrmm… it has been quite awhile. What you’re looking for is a program that returns the error code of the key entered…

There were many that would do this, but none can return more than one keystroke. Possibly if you made a simple program in QuickBasic or the like to read in a string or do the calculation and then have that program call a second batch file, passing that information on the command line?

Either way, I believe your best bet is to simply use a compiler like QuickBasic or any C or C++ compiler to create whatever util it is your looking for.

BTW, what is it you’re making?

http://www.robvanderwoude.com/datetiment.html

Go to Yesterday.bat and this guy has done it for you.

It is for work, so I probably can’t say much.

we have a batch file which gets some files onto a disk from a directory.

some recent changes where we work have meant we need to get some more files. their filenames are the date in YY/MM/DD format and a few characters. the characters are always the same so in theory I could search for “chars*.ext” which would find all files with ‘chars’ at the beginning. Problem is - this would find more files than I want (the system stores a couple of extra days for backup/safety so I would need to get yestarday’s date to get only yestarday’s file)

Anyway, since posting I have realized that I can do it using our bespoke internal system’s macros. which have some useful commands (such as “set_local date appl_date(’-1day’))”) so I am doing it using the macros.

Thanks for the help guys, anyway.

Just to defend my answer as not being completely out of whack:

Here’s the NT batch file the link daniel801 posted had for getting the date into an env var:

@ECHO OFF
FOR /F "TOKENS=1* DELIMS= " %%A IN (‘DATE/T’) DO SET DATE=%%B
ECHO It’s %DATE% today

Now this seems to work in NT (Actually, I’m just assuming, haven’t tested since don’t have NT). But this would not work in MS-DOS, which is what the OP asked for.

Nitpicking, I know, but I’m bored 'n need something to bolster my waning ego.

Melraidin You are probably right. One website I found said something along the same lines as your post. In the end I did sort of take up your suggestion. The language I wrote the macro (It is now done) is similar to basic and C (and sql, and dos, and just about every other simple language!)

If you do a lot of DOS scripting, check out 4DOS at jpsoft.com. It’s a command.com replacement, and very cool. It enables the sort of thing you want to do here and much more.

On some windows platforms (NT and XP confirmed) you can run perl straight from the commandline like this:

c:\script.pl

Perl contains very powerful string manipulation tools and basic perl is rather easy to learn. I’ve been programming perl for less than 6 months and I could easily write a program as described in the OP

On some windows platforms (NT and XP confirmed) you can run perl straight from the commandline like this:

c:\script.pl

Perl contains very powerful string manipulation tools and basic perl is rather easy to learn. I’ve been programming perl for less than 6 months and I could easily write a program as described in the OP