我必须匹配bat文件中else块中的文件模式。 * ABC * 20170202 * .TXT
以下是我需要的示例:
IF EXIST abc.txt (
ECHO "abc File exists"
TIMEOUT 5
) else (
echo *abc*20170202*.txt>> download.txt
echo File printed successful..
PAUSE
)
它不会将*视为野生角色。 请指导如何实现这一目标
修改
以下是我需要的示例:
@ECHO OFF
for /f "tokens=2*" %%a in ('net user "%USERNAME%" /domain ^| find /i "Full Name"') do set DisplayName=%%b
IF EXIST ~%~n0%~x0.loc SET /p dname=<~%~n0%~x0.loc
IF EXIST ~%~n0%~x0.loc (
ECHO *****************************************************
ECHO Script is already running by User : %dname%
ECHO *****************************************************
TIMEOUT 5
) else (
ECHO %DisplayName% > ~%~n0%~x0.loc
echo cd /abcdata/contrl>> download.txt
echo prompt>> download.txt
echo mget *abc*20170202*.txt>> download.txt
echo bye>> download.txt
ftp -s:download.txt xx.xx.xx.xx
REM "Replace xx.xx.xx.xx with a IP address"
del /Q download.txt
echo File downloded successful..
TIMEOUT 5
DEL ~%~n0%~x0.loc
)
在第echo mget *abc*20170202*.txt>> download.txt
行
它不认为*是野性字符,而是普通文本。
它应该匹配10个文件,但它没有。
以下是我在运行此
时收到的日志Connected to xx.xx.xx.xx.
220 (vsFTPd x.x.x)
User (xx.xx.xx.xx:(none)):
331 Please specify the password.
230 Login successful.
ftp> cd /abcdata/contrl
250 Directory successfully changed.
ftp> prompt
Interactive mode Off .
ftp> mget *abc*20170202*.txt
200 Switching to ASCII mode.
ftp> bye
221 Goodbye.
File downloded successful..
Press any key to continue . . .
请指导如何做到这一点。
答案 0 :(得分:1)
echo
无法按照您的想法运作。
试试这个:
dir /s/b *abc*20170202*.txt>> download.txt