0

I am doing an ftp batch script. It's an mget command but I have an error with the file name because it has ":"(colon)s in it. So my codes does a for loop which does the get command multiple times. My problem is, is that the .dat file has an empty line which is an error for the ftp command.

Below is my code:

@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

The file_list.txt is the list of file names that I need to rename using this code

setlocal enabledelayedexpansion
    for /f "delims=" %%a in (file_list.txt) do (
    set "remote=%%a"
    echo get !remote:~0,-1! !remote::=.!»second.dat)
    endlocal

The output file is this one

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

What I what is, I need to remove the blank spaces for the ftp command to read it properly

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
Karl Guevarra
  • 349
  • 2
  • 12

0 Answers0