Parameters in Batch Files

Question: Using XCOPY and the date switch ( /d ); is it possible to have the batch file prompt the user for the date to be used? If so, how would this be written.
anonymous

Answer: I don't think you can actually prompt for the date but you can set up the batch file to accept the date as a parameter like this:

if x%1x == xx goto error
xcopy /d:%1
goto end
:error
echo You forgot to enter a date
:end

This same technique can be used to process multiple parameters (using %1 - %9) in whatever processing that you require in any batch file.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate