Posted by Darryl Workman on October 09, 2007 at 14:08:17:
I am building a BAT file that will retrieve files from an FTP server that a vendor is delivering every morning. The filenames are consistent, but each includes the date of the data within, not the date the file was delivered. For example, the transaction file received on the FTP server on Oct 9 would be named transactions_2007-10-08.txt.
I know how to retrieve it if it had today's date in the name, but can someone please help me with referencing yesterday's date?
Many thanks!
Here is what I would do if it was today's date:
SETLOCAL
SET dwMONTH=%DATE:~4,2%
SET dwDAY=%DATE:~7,2%
SET dwYEAR=%DATE:~10,4%
SET dwDate=%dwYEAR%-%dwMONTH%-%dwDAY%
ECHO %dwYEAR%-%dwMONTH%-%dwDAY%
ECHO %dwDate%
then the GET commands referencing %dwDATE%.