Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9128

Windows batch, How to rename a directory to date and time with seconds

$
0
0

Windows batch,
How to rename a directory to date and time with seconds

Current drive and directory is S:\1 = a backup.

via batch, How to automate, How to rename a directory, not a file?
something like -- Rename S:\1 S:\20171022_131459

2017 year
10 October
22 day
13 hours
14 minutes
59 seconds

Below was does at the command line with one %
on a file named hope.txt, not a directory

ren hope.txt 20171022.txt

.

for /f "tokens=1-4 delims=- " %d in ("%date%") do rename "hope.txt" %d%e%f.txt

and in part 2 (time)
Seconds are missing in name and
it is not a directory, but, it does a file
named hope.txt with hours and minutes.

rename "hope.txt" 1314.txt 

.

for /f "tokens=1-2 delims=: " %G in ("%time%") do rename "hope.txt" %G%H.txt

--


Viewing all articles
Browse latest Browse all 9128

Trending Articles