A project is generated daily with a file name + date. rar file, such as the Bcpdata2012-08-31.rar file, the dynamic part is the date part, in the Windows environment variable is represented by%date:~0,10%, This file is generated to automatically upload to the FTP server, then how to do it? Here are the effective methods I've found, and I'll take a look at them here.
@echo off
echo Open IP address > Ftpcommand.txtecho FTP user name >>ftpcommand.txtecho ftp password >>ftpcommand.txtecho LCD The path to the file to be uploaded locally >>ftpcommand.txtecho the path to the upload file on the CD FTP server >>ftpcommand.txtif "%1" = = "" Pauseif "%1" = = "Get" echo Get%2%2>>ftpcommand.txtif "%1" = = "put" Echo put%2 >>ftpcommand.txtecho bye >>ftpcommand.txtftp-s:f Tpcommand.txt
Save the above script as a batch. bat file, such as Ftpcommand.bat, by using the
Upload: FtpCommand putBcpdata%date:~0,10%.rar
Download: FtpCommand get bcpdata%date:~0,10%.rar
%1 represents the first parameter of the batch, either get or put,%2, which represents the name of the file to be uploaded or downloaded, using the Windows environment variable, which enables the uploading or downloading of dynamic file names. http://www.aixchina.net/home/space.php?uid=20260&do=blog&id=32040
Automatic uploading and downloading of dynamic file names via FTP under Windows