In a batch file I need to get a file from a folder that has today's date.
The problem is I can't get the batch date command to return the proper format.
I have this: echo %date:/=-%
But that always returns for example: Fri 06-20-2014
What's the proper call for just returning: 06-20-2014
Looked all over can't find.
Thanks!
This works independent of regional date/time format:
for /f %%I in ('wmic os get localdatetime ^|find "20"') do set dt=%%I
REM dt format is now YYYYMMDDhhmmss...
set dt=%dt:~4,2%-%dt:~6,2%-%dt:~0,4%
echo %dt%
set "$date=%date:~4%"
set "$date=%$date:/=-%"
echo %$date%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With