我正在做一个ftp批处理脚本。这是一个mget命令,但我的文件名有错误,因为它中有“:”(冒号)。所以我的代码执行for循环,多次执行get
命令。我的问题是,.dat文件有一个空行,这是ftp命令的错误。
以下是我的代码:
@echo off& setlocal enableextensions
Echo open sample.net>second.dat
Echo user»second.dat
Echo pass»second.dat
Echo ascii»second.dat
Echo cd path/path/path»second.dat
setlocal enabledelayedexpansion
for /f "delims=" %%a in (file_list.txt) do (
set "remote=%%a"
echo get !remote:~0,-1! !remote::=.!»second.dat)
endlocal
Echo bye»second.dat
ftp -v -i -s:second.dat
del second.dat
pause
file_list.txt
是我需要使用此代码重命名的文件名列表
setlocal enabledelayedexpansion
for /f "delims=" %%a in (file_list.txt) do (
set "remote=%%a"
echo get !remote:~0,-1! !remote::=.!»second.dat)
endlocal
输出文件是这个
sample.net
user
pass
ascii
cd path/path/path
get logsample-txt-871749063-10-17-2017_22:00:05:692474.txt logsample-txt-871749063-10-17-2017_22.00.05.692474.txt
get logsample-txt-871749063-10-18-2017_08:00:57:671751.txt logsample-txt-871749063-10-18-2017_08.00.57.671751.txt
get logsample-txt-871749063-10-18-2017_08:00:07:724779.txt logsample-txt-871749063-10-18-2017_08.00.07.724779.txt
bye
我是什么,我需要删除ftp命令的空格来正确读取
sample.net
user
pass
ascii
cd path/path/path
get logsample-txt-871749063-10-17-2017_22:00:05:692474.txt logsample-txt-871749063-10-17-2017_22.00.05.692474.txt
get logsample-txt-871749063-10-18-2017_08:00:57:671751.txt logsample-txt-871749063-10-18-2017_08.00.57.671751.txt
get logsample-txt-871749063-10-18-2017_08:00:07:724779.txt logsample-txt-871749063-10-18-2017_08.00.07.724779.txt
bye