【问题标题】:Create Batch File that prompts user for File path in DOS 6.22在 DOS 6.22 中创建提示用户输入文件路径的批处理文件
【发布时间】:2018-04-22 18:30:01
【问题描述】:

我正在尝试在 DOS 6.22 中创建一个 .BAT 文件,它将 A: 中的软盘内容复制到 C:\,然后将创建的文件夹设置为系统变量。我尝试使用类似 "SET /P VARIABLE=Enter a path" 之类的东西,但是 DOS 只会将 "/P VARIABLE" 添加为值为 "Enter a path" 的变量,因此使用 /P 是'不是一个选项,因为 /P 不是 DOS 6.22 中的开关

我尝试使用 for 循环之类的东西为文件设置一个变量,但是我遇到减速带的地方是我不知道在驱动器 A:\ 中将调用什么文件夹,因为它会改变所有时间但只包含一个文件夹,所以基本上我只是想找到一种方法将驱动器 A 中的第一个目录复制到 C:\ 并将其设置为系统变量。一旦用户完成更改,我将不得不将该文件夹复制回 A:\ 并覆盖旧文件,以便在进行更改后将其存储在网络上。

我确实尝试过通过 .BAT 文件尝试一些 If/for 语句,但我对这些论文的运气并不好,如果有人能指出我正确的方向,那就太棒了。

在这一点上,我可能会让这种方式变得比我必须做的更复杂。

【问题讨论】:

标签: batch-file dos


【解决方案1】:

这样的东西也应该起作用:

 @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

【讨论】:

    【解决方案2】:

    在对@Squashman 链接的内容进行了更多研究后,我最终找到了解决方案。结果发现通信出现故障,这甚至不是用户遇到的原始问题(一种从 A:\ 复制文件的简单方法以及所有这些)

    我使用了以下内容。

     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
    

    这是我在此处找到的指南的修改版本。 http://www.pement.org/sed/bat_env.htm#4dos

    希望这能够对某人有所帮助,尽管想象起来并不漂亮,但它确实有效。

    【讨论】:

    • 他们似乎更容易输入myscript dirname
    【解决方案3】:

    如果您的用户实际上只需要复制一个目录,我认为这对您的用户来说会更容易。

    @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
    

    【讨论】:

      猜你喜欢
      • 2017-10-07
      • 1970-01-01
      • 2015-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-18
      • 2018-07-04
      相关资源
      最近更新 更多