Hello and thank you for reading.
I want to write short script to upate files and creating a backup before overwriting.
My problem now is to rename the file with a timestamp before i overwrite is with the new one.
At the moment i'm getting the timestamp this way:
Code
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set stamp=%YYYY%%MM%%DD%
Unfortnuatly this doesnt work on every PC - i guess the reason is that wmic is not supported in every Windows Versions.
(I want to use the script on WIN NT, XP, 7, 10)
I was thinking about the %date% variable but also here the content is different from version to version - but the date numbers are inside.
Now my question is: is it possible to just filter out the numbers in the %date% variable
Here i got 2 different date contents from Win10 and Win7:
Win 10: 05.10.2018
Win 7: Fri 10/05/2018
The Win 10 content would work with the rename step: filename_%date%.exe ->filename_05.10.2018.exe
With the Win7 i got problems due the "/" symbols.
If i can get in my example just 05102018 out of the %date% that would be great - is it possible?
This post was edited by Phiro on Oct 5 2018 02:21am