I'm writing a *.bat
file (Windows) in which I use FTP commands to get remote files back on a local machine. The remote directory includes a archive
subdirectory in which I want to move the files once they are downloaded on the local machine.
My script in the *.bat
file:
ftp -v -i -s:GET_FILES_FTP.txt
My script in GET_FILES_FTP.txt
:
open example.com
username
password
lcd S:\
lcd repository/files
mget *.txt
rename *.txt archive/
disconnect
bye
Note that hostname, username and password are not those I use for real!
The TXT files are downloaded properly on the local machine.
The problem is that rename *.txt archive/
is not interpreted and the files do not move to the archive
file. I the command window, I get a directory not found
error message. I can't find extra information better than this doc.
Any idea on how to move the files?
The
rename
command of the Windowsftp.exe
does not support wildcards.You would have to dynamically generate a script file based on a list of downloaded files with a separate
rename
command for each file.Or use a different command-line FTP client that supports wildcards when renaming/moving.
For example with WinSCP scripting the batch file would be like:
For details see:
mv
command(I'm the author of WinSCP)