我有这个批处理代码,它仅在文件名称中没有空格时才有效。 如何查找名称中包含空格的文件?
@echo off
echo.open localhost >file.tmp
echo.user user1 user1 >>file.tmp
echo.dir >>file.tmp
echo.bye >>file.tmp
FTP -n <file.tmp >output.tmp
Del file.tmp
echo.open localhost >file.tmp
echo.user user1 user1 >>file.tmp
FOR %%A IN (*.*) DO call :Existe %%A
echo.bye >>file.tmp
FTP -n <file.tmp >nul
DEL file.tmp
DEL output.tmp
GOTO :EOF
:Existe
Findstr /I %1 output.tmp > nul
IF NOT %ErrorLevel% == 0 ECHO.put %1 >>file.tmp
我也这样做,但它不起作用
:Existe
Findstr /I /c:"%1" output.tmp > nul
IF NOT %ErrorLevel% == 0 ECHO.put "%1" >>file.tmp
答案 0 :(得分:1)
^|find /V "%0"
@echo off
Set "Host=localhost" & If "%~1" neq "" Set "Host=%~1"
Set "User=user1" & If "%~2" neq "" Set "User=%~2"
Set "Pass=user1" & If "%~3" neq "" Set "Pass=%~3"
(echo.open %Host%
echo.user %User% %Pass%
echo.dir
echo.bye
) >file.tmp
FTP -n <file.tmp >output.tmp
Del file.tmp
(echo.open %Host%
echo.user %User% %Pass%
FOR %%A IN (*.*) DO call :Existe "%%A"
echo.bye
) >file.tmp
FTP -n <file.tmp >ftp.log
DEL file.tmp
DEL output.tmp
GOTO :EOF
:Existe
Echo:%~1|Findstr /I "\.tmp$ \.cmd$">NUL 2>&1 && Goto :Eof
Findstr /I "%~1" output.tmp >nul 2>&1 ||ECHO.put "%~1"