Reputation: 18645
I have a batch file to run a defrag on a computer - as below. At the moment it is creating the text file named ComputerName.txt
@echo off
defrag.exe c: -f -v >"C:\Defrag\ComputerName.txt"
How can I get the date to also ammend to the end of the text file? IE:
ComputerName.2011.02.08.txt
Upvotes: 2
Views: 2801
Reputation: 1319
for /f "tokens=2-4 delims=/- " %%A in ('date /T') do set var=c:\defrag\ComputerName.%%C.%%A.%%B.txt
defrag c: -f -v > %var%
Upvotes: 1