congdantoancau

Rename file with timestamp

Nov 11th, 2021 (edited)
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.38 KB | None | 0 0
  1. ::https://stackoverflow.com/questions/203090/how-do-i-get-current-date-time-on-the-windows-command-line-in-a-suitable-format
  2.  
  3. For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
  4. For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
  5. set renamed_time=%mydate%_%mytime%
  6. ren c:\new\file.txt file_%renamed_time%.txt
  7. xcopy d:\file.txt c:\new\file.txt
Advertisement
Add Comment
Please, Sign In to add comment