I wrote a script to copy a file from ftp
@echo off
ftp -s:ftp.txt
pausaand the ftp.txt Contains :
open= ftp server
username
password
get ://ftpserver/ghwt/jdtt_05gbser.txt
quitnow i wont to Improve it to copy only yesterday file, What and Where I should add in my script?
message edited by Tzvi
@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%"Does this help?
If you can't generate the ftp-filename from your end, you have a long row to hoe: download a "dir" of the ftp directory, convert dates, subtract converted dates from today's date, download all files that qualify. If it came to that, I would strive, mightily, to find a better way. "jdtt_05gbser.txt" tells me zilch about any relationship to previous filenames or the file's date.
Hi Twittee,
your script is very good but still i dont understand how to copy only yesterday's files
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |