I want to name a file using the current date and time in a specific format.
To do so, I have the following code to set %datetime%
to the format I want.
Example: 2017-06-19 05_00_00
for /f %%a in ('powershell -Command "Get-Date -format yyyy-MM-dd\ HH_mm_ss"') do set datetime=%%a
This isn't quite working. I'm 99% sure it is due to the space between the date and time, which I want.
What is the error, and how can it be fixed?
(Note that I cannot depend on WMIC being available, so calling Powershell is probably the best solution. Regardless, I'm interested in learning how to get this specific code to work.)