There are 6 things you need:
1 FTP Server Name (FTP Site name, either the name or IP address
2 UserName for the FTP Account
3 Password for the FTP Account
4 Local Folder, where on your PC you want to store the file
5 Remote Folder, where the file is on the FTP Server
6 Filename, the name of the file to retrieve
The Remote folder path should be relative to the folder you are in when you log onto the ftp site. This is case sensitive
The file name is also case sensitive.
If you don't know the name, you can download all files with a csv extension.
If this remote folder will have all of the previous files, you can get a list of files then download only those you don't have, but this gets much more complicated.
If the file name includes the date, you can check for that as well.
If the filename starts with the date, you can also download all files that start with today's (or yesterday's) date.
Edit the first 6
Set statements with the correct info to get one file. Only change the part shown in red.
Code:
@Echo Off
Set _FTPServerName=ftp site address
Set _UserName=username
Set _Password=password
Set _LocalFolder=C:\FTPFiles
Set _RemoteFolder=Public\Reports\CSV
Set _Filename=report.csv
Set _ScriptFile=ftp1
:: Create script
>"%_ScriptFile%" Echo open %_FTPServerName%
>>"%_ScriptFile%" Echo %_UserName%
>>"%_ScriptFile%" Echo %_Password%
>>"%_ScriptFile%" Echo lcd %_LocalFolder%
>>"%_ScriptFile%" Echo cd %_RemoteFolder%
>>"%_ScriptFile%" Echo binary
>>"%_ScriptFile%" Echo get %_Filename%
>>"%_ScriptFile%" Echo quit
:: Run script
ftp -s:"%_ScriptFile%"
Del "%_ScriptFile%"
Edit the first 5
Set statements in this version to get all *.csv files. Only change the part shown in red:
Code:
@Echo Off
Set _FTPServerName=ftp site address
Set _UserName=username
Set _Password=password
Set _LocalFolder=C:\FTPFiles
Set _RemoteFolder=Public\Reports\CSV
Set _Filename=*.csv
Set _ScriptFile=ftp1
:: Create script
>"%_ScriptFile%" Echo open %_FTPServerName%
>>"%_ScriptFile%" Echo %_UserName%
>>"%_ScriptFile%" Echo %_Password%
>>"%_ScriptFile%" Echo lcd %_LocalFolder%
>>"%_ScriptFile%" Echo cd %_RemoteFolder%
>>"%_ScriptFile%" Echo binary
>>"%_ScriptFile%" Echo prompt
>>"%_ScriptFile%" Echo mget %_Filename%
>>"%_ScriptFile%" Echo quit
:: Run script
ftp -s:"%_ScriptFile%"
Del "%_ScriptFile%"
Ignore the spaces in front of the red text. The Forum editor insists on adding spaces. The red text starts immediatly after the =