How would I append Date, Time, and Second to all of my folder names.
for /D %%f in (C:\Reports*) do rename "%%f" "%%~nxf"
How would I append Date, Time, and Second to all of my folder names.
for /D %%f in (C:\Reports*) do rename "%%f" "%%~nxf"
This will rename folders to the following format: Folder Name YYYY-MM-DD-HH-MM
. Sorry no seconds resolution in batch unless you use robocopy
or forfiles
. I am assuming you wanted the last modified date and time appended onto the folder name. If you want a different date you need to specify as much.
Year = %%V
,
Month = %%T
,
Day = %%U
,
Hour = %%W
,
Minute = %%X
, and
Meridiem = %%Y
@echo off
pushd "C:\Reports"
for /D %%D in (*) do for /f "tokens=1,2,3,4,5,6 delims=/: " %%T in ("%%~tD") do rename "%%~fD" "%%~nxD %%V-%%T-%%U-%%W-%%X"
popd