Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can any one help me to Automatically create Folder/Files according to the current system date using in Batch file?
Leonard B.

First you need to take a look at your DATE layout.
Mine is:
Tue 13-12-2005
So if I do:
echo %date:~10,4%%date:~7,2%%date:~4,2%
I get:
20051213
Given that, I can:
md %date:~10,4%%date:~7,2%%date:~4,2%
to make a directory or, to make a file:
type nul > %date:~10,4%%date:~7,2%%date:~4,2%.txt
If at first you don't succeed, you're about average.M2

I tried in command prompt
C:\Documents and Settings\wb261923>echo %date:~10,4%%date:~7,2%%date:~4,2%
After this I got the following result..003/
My date setting is mm,dd,yy
Why I am not getting your result like: 20051213please help.
Leonard B.

You need to post your EXACT date layout.
Do this:
echo %DATE%
If at first you don't succeed, you're about average.M2

Would you please type the complete command and its output of this process? So that I can understand whats wrong with mine.
LEoLeonard B.

Sure, but I need the DATE layout.
Do this:
echo %DATE%
and post result.
If at first you don't succeed, you're about average.M2

Hi Leonard,
I think this is the syntax you need:
echo %date:~6,4%%date:~0,2%%date:~3,2%
Let us know.
If at first you don't succeed, you're about average.M2

YESS!!!!!!!!!!!! It Works!!!! Thank you verymuch! U save my Day. How the syntex working here acctually? Maybe I can make change for need.
Leonard
Leonard B.

Hi Leonard,
the syntax gets the specified parts of a string.
echo %string:~x,y%
means to skip the first x characters and use the next y chars.
Does that make sense?
If at first you don't succeed, you're about average.M2

Hello,
I got the picture. Here is an example of date pattern I decided to use for my auto folder naming.C:\Documents and Settings\wb261923>echo %date:~6,4%_%date:~0,2%_%date:~3,2%
2005_12_17
That's it!! Cool huh?
Thanks to you BOSS.Leo
Leonard B.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |