1.

Solve : Batch file to fetch user defined file?

Answer»

I'm looking to make a batch file that would ask the user to enter a 2 digit number to specify what file they need.  The files are located in a shared folder with each file located in a folder named XXXXXX## with the ##'s representing the 2 digits I would want the user to enter.  I can cover the rest as far as fetching the files and where to put them etc.

Thanks in advance, you guys really helped me last time and I'm sure this one will be a snap compared to that  Here's a simple way that works on all versions of DOS

Mac

Code: [Select]ECHO off
echo.
if x%1==x (
  echo You forgot the two digit code. Please try again
  echo.
  echo Format is %0 xx
  echo where xx is your two digit code
  goto Adios
)
if not exist xxxxx%1\*.* (
  echo That was an invalid code. Try again.
  echo Unable to find directory xxxxx%1
  goto Adios
)
{at this point you have your directory}
Quote

Here's a simple way that works on all versions of DOS
Actually, the parenthesis grouping in an IF statement is not SUPPORTED in DOS 6.x and older or Windows 9x.

Dam1an: What version of DOS are your users running?  If it is Windows 2000 / XP / 2003 / VISTA  you can try something like this:
Code: [Select]echo off
set /p number=Please enter the 2-digit code for your file:
echo The directory specified is xxxxxx%number%
You may want to add more error checking, but I THINK that is the basics of what you want.How do you see version number? All I see is
Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.

Mac
Thank you GuruGary, that WORKED great.  
 
QBasicMac: You can use the VER command to tell the DOS version.  If it is really DOS, it will return a string like MS-DOS Version 6.22.  If it is a command processor running under Windows it will return a string like Microsoft Windows 2000 [Version 5.00.2195].  You can also look up the version of your command processor extensions (under supported operating systems) with the command:
Code: [Select]echo %cmdextversion%
Dam1an: Glad it worked


Discussion

No Comment Found