Paste the script below into a text file with a .cmd extension. Customize the indicated variable values with your local directory, remote directory of the files on the server, server name (or IP), username, and password. Running the script will create an FTP script on the fly, execute it, then delete it.
Embedding the password in a script isn't the best practice from a security perspective, so you might want to change line 9 to something like this:
set /P pw=Enter your FTP password:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
|
@echo off
setlocal
REM Customize these values
set localdir=c:\incoming\RH
set remotedir=\remotefiles
set server=yourftpserver.example.com
set user=yourusername
set pw=yourpassword
set mmdd=%date:~3,2%%date:~0,2%
if exist ftpscript.txt del ftpscript.txt
echo lcd "%localdir%" >> ftpscript.txt
echo open %server% >> ftpscript.txt
echo user %user% >> ftpscript.txt
echo %pw% >> ftpscript.txt
echo binary >> ftpscript.txt
echo prompt n >> ftpscript.txt
echo cd "%remotedir%" >> ftpscript.txt
echo mget RH_POSTAL-%mmdd%-*.zip >> ftpscript.txt
echo bye >> ftpscript.txt
ftp -n -s:ftpscript.txt
if exist ftpscript.txt del ftpscript.txt
|
Open in New Window
Select All