标题: 怎样按照指定的输入复制指定的文件
[打印本页]
作者: yaya2006
时间: 2006-11-17 22:29
标题: 怎样按照指定的输入复制指定的文件
我有道批处理的程序编不出来了,请教一下:当输入a时,从指定位置或输入的参数位置拷贝一个文件;当输入b时,把c盘的txt文件,文件名及内容显示出来。我想了好久还是不能理解
[
Last edited by namejm on 2006-11-22 at 06:37 PM ]
作者: NaturalJ0
时间: 2006-11-17 23:04
你可以查看下 CHOICE 这个命令,应该能帮上你。
附件
1:
choice.zip (2006-11-17 23:04, 17.97 K, 下载附件所需积分 1点
,下载次数: 12)
作者: hxuan999
时间: 2006-11-23 00:35
随便写了一个,知道你要的是不是这个效果.
Quote: |
- @echo off
- :in
- echo.
- set /p in="Input a or b ... (X=exit) > "
- if "%in%"=="" goto in
- if "%in%"=="x" goto end
- if "%in%"=="X" goto end
- if "%in%"=="a" goto a
- if "%in%"=="A" goto a
- if "%in%"=="b" goto b
- if "%in%"=="B" goto b
- goto in
- :a
- set /p infile="Input a file, path and name ... "
- if "%infile%"=="" goto a
- if exist "%infile%" (
- copy /y "%infile%" c:\
- ) else (
- echo "%infile%" is not exist!
- )
- goto in
- :b
- for /f "usebackq" %%f in (`"dir /b c:\*.txt"`) do (
- echo ----[%%f]----
- type "c:\%%f"
- )
- goto in
- :end
- exit 0
hxuan?表ー: 2006-11-22 11:35 |
|
[
Last edited by hxuan999 on 2006-11-22 at 12:40 PM ]