Hello,
I have a .txt file with this content (it's a date with a "space" character at the end of the string):
20/02/2020
I need to bring the characters for have a YYYYMMDD format, like this (without the slash):
20200220
How can I do it?
Thank you
Bring some characrets from a .txt and "tidy" them
Moderator: DosItHelp
-
- Posts: 2
- Joined: 19 Feb 2020 04:47
Re: Bring some characrets from a .txt and "tidy" them
You might want to use a for/f-loop to split the parts of the date:
Note that dates are localized strings and therefore highly system dependent.
penpen
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
set "input=20/02/2020 "
for /f "tokens=1-3 delims=/ " %%a in ("%input%") do set "timestamp=%%~c%%~b%%~a"
echo("%timestamp%"
goto :eof
penpen