Page 1 of 1

Batch file to create file on todays date

Posted: 30 Sep 2013 12:37
by foncesa
Hi,
I need to create 3 empty text files on todays date the format is 011013A, 011013B, 011013C, its ddmmyy.
The below batch does create a empty file but i tried to change the format but failed to achive the results. Will some help me to create 3 text files in one time with this format ddmmyy+A,B,C.

Code: Select all

@echo off
set tdtd=none
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set tdtd=%%j%%i%%k
set tufn=%tdtd%%A.txt
type NUL>%tufn%

Re: Batch file to create file on todays date

Posted: 30 Sep 2013 13:23
by Endoro
try this:

Code: Select all

@echo off &setlocal
for /f "tokens=2delims==" %%a in ('wmic os get localdatetime /value') do set "mydate=%%a"
set "mydate=%mydate:~6,2%%mydate:~4,2%%mydate:~2,2%"
for %%a in (A,B,C) do type nul>%mydate%%%a.TXT
dir %mydate%?.TXT

This works for XP Pro or better.

Re: Batch file to create file on todays date

Posted: 30 Sep 2013 19:13
by foncesa
Hi,
Perfect, Thanks Endoro