1

I am trying to create a .BAT file in DOS 6.22 that will copy the contents of a floppy disk in A: over to C:\ and then set the folder created as a system variable. I tried using something like "SET /P VARIABLE=Enter a path" however DOS will just add "/P VARIABLE" as a variable with the value of "Enter a path" so using the /P isn't an option as /P wasn't a switch in DOS 6.22

I tried using something like a for loop to set a variable to the file however where I hit a speed bump is that I have no idea what the folder is going to be called in drive A:\ as it will change all the time but only ever contain one folder, so basically I am just trying to find a way a way to copy the first directory found in drive A over to C:\ and set that as a system variable. As once the user is done making changes I will have to copy that folder back over to A:\ and overwrite the old files so it can be stored on the network once changes have been made.

I did try experimenting with some If/for statements through a .BAT file but I didn't have much luck with theses, if anyone could point me in the right direction that would be awesome.

At this point I'm probably making this way more complicated than I have to.

  • 1
    Possible duplicate of [In Windows cmd, how do I prompt for user input and use the result in another command?](https://stackoverflow.com/questions/1223721/in-windows-cmd-how-do-i-prompt-for-user-input-and-use-the-result-in-another-com) – Wai Ha Lee Nov 09 '17 at 16:48
  • 3
    @WaiHaLee, they specifically said they are using DOS 6.22. The `SET /P` command does not work in DOS 6.22. – Squashman Nov 09 '17 at 16:51
  • @WaiHaLee surely not a dupe of that .DOS (`command.com`) is way more primitive than the Windows Command Prompt (`cmd.exe`). Also thegiancat already tried that without success. – Stephan Nov 09 '17 at 16:51
  • 1
    Here is a tutorial on getting user input within dos. http://www.robvanderwoude.com/userinput.php#DOS – Squashman Nov 09 '17 at 16:52
  • 2
    is there a specific reason you need to use DOS in this era? It's even more painful to work with than cmd.exe – phuclv Nov 09 '17 at 16:59
  • To answer your question about needing DOS unfortunately we have some old PLC programming software for Texas Instrument PLCs that only runs in DOS, so until we upgrade them we are stuck running it in a VM. @Squashman I will try running through what you linked when I get back from lunch if it works I'll mark it as resolved. – thegiantcat Nov 09 '17 at 17:04

3 Answers3

1

something like this should work too:

 @echo off
 :INPUT.BAT puts what is typed next in environment variable INPUT
 set input=
 echo INPUT.BAT
 echo Type in something and press [Enter]
 fc con nul /lb1 /n|date|find "    1:  ">temptemp.bat
 echo :Loop>>enter.bat
 echo if not (%%input%%)==() set input=%%input%% %%5>>enter.bat
 echo if (%%input%%)==() set input=%%5>>enter.bat
 echo shift>>enter.bat
 echo if not (%%5)==() goto Loop>>enter.bat
 for %%x in (call del) do %%x temptemp.bat
 del enter.bat
 echo The string you just entered:
 echo %input%
 echo has been stored in an environment variable named INPUT
 :End
Mark Deven
  • 550
  • 1
  • 9
  • 21
0

I ended finding a solution after doing some more research from what @Squashman linked. Turns out there was a breakdown in communication and this wasn't even the original issue that the user had (a simple way to copy the files off A:\ and all that)

I used the following.

 echo Type "set myvar="name of the folder" replacing name of the folder with 
 echo the name of the folder containing the files on A:\ example if you were 
 echo  on "example" you would type: set myvar=example      
 copy con answer.bat
 echo Type the words "set myvar=" (don't type the quote marks)
 echo and then immediately after the = sign, press Control-Z then enter
 call answer.bat
 mkdir C:\%myvar%
 xcopy A:\%mvar% C:\%myvar%
 DEL answer.bat

This is a modified version of a guide I found here. http://www.pement.org/sed/bat_env.htm#4dos

Hopefully this is able to help someone, this isn't pretty by any stretch of the imagination but it worked.

0

I think this would be easier for your users if they actually need to only copy one directory.

@echo off
if "%1" == "" goto syntax
md C:\%1
xcopy/E A:\%1 C:\%1 
goto end
:syntax
echo Please input a directory after %0
:end