curl - add variable in url batch programming
I have a batch file where I have a variable which prints date in YYYYMMDD - 20160403
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2% echo Local date is %ldt%
then I am downloading a file which has the date a the end of the url
curl "http://www.example.com/cgi-bin/abc.xyz/%ldt%.txt" -o file-name-%ldt%.txt
where %ldt% has the date for eg: 20160403
but now I am not able to print the date. Any suggesstions ?
%date% is an internal windows variable. It is not wise to overwrite it. Use another variable name (for example %myDate%).
By the way: you can restore the original windows variable by (no joke) deleting it: set "date="