how to copy yesterday file from ftp via a batch file?

October 29, 2014 at 12:47:33
Specs: Windows 7
I wrote a script to copy a file from ftp

@echo off
ftp -s:ftp.txt

and the ftp.txt Contains :

open= ftp server
get ://ftpserver/ghwt/jdtt_05gbser.txt

now i wont to Improve it to copy only yesterday file, What and Where I should add in my script?

message edited by Tzvi

See More: how to copy yesterday file from ftp via a batch file?

Report •

January 22, 2015 at 15:13:01
@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?

Report •

January 22, 2015 at 19:01:43
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.

Report •

January 23, 2015 at 01:32:40
Hi Twittee,
your script is very good but still i dont understand how to copy only yesterday's files

Report •

Related Solutions

Ask Question