Batch file to create file on todays date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Batch file to create file on todays date

#1 Post by foncesa » 30 Sep 2013 12:37

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%

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: Batch file to create file on todays date

#2 Post by Endoro » 30 Sep 2013 13:23

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.

foncesa
Posts: 42
Joined: 12 Sep 2013 00:09

Re: Batch file to create file on todays date

#3 Post by foncesa » 30 Sep 2013 19:13

Hi,
Perfect, Thanks Endoro

Post Reply