0

How would I append Date, Time, and Second to all of my folder names.

for /D %%f in (C:\Reports*) do rename "%%f" "%%~nxf"

Jerry Trac
  • 357
  • 4
  • 17
  • See http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us. – shf301 Jan 04 '13 at 22:50

1 Answers1

1

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
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47