Wild Cards * in If Else Statements - Batch Scripting

I have to match a file pattern in else block in a bat file. abc20170202*.txt

Below is a example where I need this:

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 *****************************************************
) 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..
DEL ~%~n0%~x0.loc

At line echo mget abc20170202*.txt>> download.txt it does not considers * as wild character and rather normal text. It is supposed to match 10 files, however it doesn’t.

Below is the log I receive on running this

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 abc20170202*.txt
200 Switching to ASCII mode.
ftp> bye
221 Goodbye.
File downloded successful…
Press any key to continue . . .

Please guide how this can be done.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.