我创建了一个.bat文件,我输入了一个作业号。我想使用带有通配符的输入值将一个文件夹的内容复制到仅具有输入值的另一个文件夹。它不会使用通配符复制此文件夹的内容。有什么建议吗?
样品:
Input = 19000
c:\test2\19000 project\test.doc
c:\test\19000
下面的.bat文件
COLOR 0a
:USERID
CLS
ECHO Enter User Name:
ECHO > NUL
SET /p USERID=
IF %USERID% EQU c GOTO PASSWORD
IF %USERID% LSS c GOTO INVALID
IF %USERID% GTR c GOTO INVALID
:PASSWORD
CLS
ECHO Enter Password:
SET /p PASSWORD=
IF %PASSWORD% EQU c GOTO :job number
IF %PASSWORD% LSS c GOTO INVALID
IF %PASSWORD% GTR c GOTO INVALID
CLS
:INVALID
ECHO INAVLID LOGIN.....
PING -n 3 127.0.0.1 > NUL
ECHO Please try again...
PING -n 3 127.0.0.1 > NUL
GOTO USERID
:Job Number
Set input1=
set /p input1= Job Number:
cls
ECHO OFF
c:
cd\
xcopy "c:\test2\%input1% "*" " "c:\test\%input1%" /e
cd\
c:
cls
EOF
exit
答案 0 :(得分:0)
这应该将与查询匹配的任何文件夹与其后面的通配符一起xcopy到具有相同文件夹结构的c:\test\
文件夹。
@echo off
COLOR 0a
CLS
:USERID
SET /p "USERID=Enter User Name: "
IF "%USERID%" NEQ "c" GOTO INVALID
ECHO(
SET /p "PASSWORD=Enter Password: "
IF "%PASSWORD%" NEQ "c" GOTO INVALID
ECHO(
Set "input1="
set /p "input1=Job Number: "
for /d /r "c:\test2\" %%a in ("%input1%*") do (
xcopy "%%a\*.*" "c:\test\%%~nxa\" /s/h/e/k/f/c
)
cls
exit
goto :EOF
:INVALID
ECHO INVALID LOGIN.....
PING -n 3 127.0.0.1 > NUL
ECHO Please try again...
PING -n 3 127.0.0.1 > NUL
goto :userid