I have the following requirements to perform FTP file moves between two FTP servers, basically doing (PULL/GET and PUSH/PUT) of files.
The FTP Transaction consists of 4 Actions:
1. Get listing of remote files from remote FTP server and save listing to a file eg. ftplistfiles.log)
2. Copy list of remote files to the local ftp (eg. /localftp/incoming) folder until next scheduled batch run
3. Backup copied files to a separate folder
(eg. /localftp/incoming/backup-datetimestamp )
4. Delete list of files REMOTELY after action 1,2,3 is successful.
I HAVE DONE ACTIONS 1,2,& 3 SO FAR:
Action 1. Completed via batch file with sample following commands. Please note I'm a novice and just started learning batch file so forgive my syntax for obvious errors. This is just sample code as there was more code than shown below:
cmd.exe /c ftp -i -s:listing.scr > ftplistfiles.log
The contents of the ftplistfiles.log after performing an 'ls' command remotely via ftp listing.scr
Now, my question is how do you insert/prepend using Windows/DOS batch scripting the following ftp lines such as 'open ftp.remote.com' etc... and the word DELETE before the filename in the list of files in the ftplistfiles.log ?
Desired Content of transformed ftplistfiles.log should be something like after issuing 'type' command below:
The transformed file ftplistfiles.log will be used as ftp input script to the ftp command to DELETE remote files. As in:
ftp -i -s:ftplistfiles.log
I even used something like:
FOR /F "tokens=2* delims=." %%A IN ('type ftplistfiles.log') DO echo (set _delete.%%A)
But I was getting notdefined environment vars. _delete.<filename> even though the variable was set.
Any help or directions on how to do achieve ACTION4-delete remote files, is very much appreciated as I'm stuck on the last action.