First of all: Why I'm trying this? Because we need to download some files AND rename to shorten ones with date "stamps". The remote files have really huge filenames and it's not an option to change(isn't our ftp).
I'm trying to make a bulk download and rename of some files in a remote ftp server, without having to open one ftp connection to each file I have to download. So far, i could achieve renaming and download on-the-fly with
nmap ftp command, renaming every file that starts with "N" and ends with ".TXT" to "N_date_time_stamp.TXT"
ftp -niv $url << FTP_COMMAND user $user $password cd $remotedir nmap N*.TXT N_`date "+%H%M%N"`.TXT mget N* bye FTP_COMMAND
The problem is: nmap keeps the same %N value to all files passed to mget, and it should change on every download to the current nanosecond value:
250 CWD command successful. local: N_1054232349627.TXT remote: NO2346662345257245624572457245724562411125555341346134771345123461146-44.TXT 227 Entering Passive Mode (xxxxxxxxxxxxxxx). 125 Data connection already open; Transfer starting. 226 Transfer complete. 2220 bytes received in 0,0995 secs (22 Kbytes/sec) local: N_1054232349627.TXT remote: NO2346662345257245624572457245724562411125555341346134771345123461146-45.TXT 227 Entering Passive Mode (xxxxxxxxxxxxxx). 125 Data connection already open; Transfer starting. 226 Transfer complete. 2220 bytes received in 0,107 secs (20 Kbytes/sec)
Is there a way to update the
nmap on each download?