Solved convert the date format

October 19, 2020 at 01:17:15
Specs: Windows 10
need to get the file last modified date
and convert the date the as below format
YYYY/MM/DD no need time



See More: convert the date format


✔ Best Answer
October 20, 2020 at 03:16:39
Not tested because I'm not using that date fmt.
=========================================
@echo off & setLocal enableDELAYedeXpansioN


for /f "tokens=* delims= " %%a in ('dir/b') do (
set D=%%~Ta
set N=!D:~6,4!/!D:~0,2!/!D:~3,2!
echo.!N!
)
goto :eof

=====================

M2



#1
October 19, 2020 at 02:24:34
It might be a REAL GOOD IDEA to say what format you're starting with.

=====================

M2


Reply ↓  Report •

#2
October 19, 2020 at 10:21:16
Here is an example in PowerShell Script:

GI "$Env:Temp\*.*" | % {$_.FullName; '{0:yyyy/MM/dd}' -f $_.LastWriteTime}


Reply ↓  Report •

#3
October 19, 2020 at 19:19:31
Batch version, may or may not work depending on localE settings for file date format:
@echo off & setlocal
for %%a in (file) do set d=%%~ta
for /f "tokens=1-3 delims=/ " %%a in ("%d%") do echo %%c/%%a/%%b

Reply ↓  Report •

Related Solutions

#4
October 19, 2020 at 22:46:58
You can take a look at this ==> How get data/time independent from localization

@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set dt=%%a
set datestamp=%dt:~0,8%
set timestamp=%dt:~8,6%
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%
set stamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%
echo stamp: "%stamp%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"
echo I want my date like that %YYYY%/%MM%/%DD%
pause


Reply ↓  Report •

#5
October 20, 2020 at 01:42:20
He asked to re-jigger the date format of a FILE.

As yet, we don't know what that is.

#1 has been ignored.

=====================

M2


Reply ↓  Report •

#6
October 20, 2020 at 01:59:29
Date format of file: 10/19/2020 01:32 PM
Need to convert the above date as
2020/10/19

Reply ↓  Report •

#7
October 20, 2020 at 03:16:39
✔ Best Answer
Not tested because I'm not using that date fmt.
=========================================
@echo off & setLocal enableDELAYedeXpansioN


for /f "tokens=* delims= " %%a in ('dir/b') do (
set D=%%~Ta
set N=!D:~6,4!/!D:~0,2!/!D:~3,2!
echo.!N!
)
goto :eof

=====================

M2


Reply ↓  Report •

Ask Question