|
|
| Author |
Message |
Guest
|
Posted: Fri Apr 21, 2006 3:36 pm Post subject: Need help creating batch file to create directory with the d |
|
|
Hi there,
I need to write a batch file to create a directory with the format
mm-yy. The script will be running on a windows 2003 server. The job
will be scheduled to run on a server every night.
I have an old one from a windows 2000 server but it doesn't work (and
it gives me the folder name in the format mm-yyyy). The code is below:
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET
datestring=%%b-%%c
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET monthstring=%%b
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET YearToDo=%%c
d:
cd c
mkdir %datestring%
cd %datestring%
Can anyone help me out with this problem. |
|
| Back to top |
|
 |
|
|
Pegasus (MVP) Guest
|
Posted: Fri Apr 21, 2006 3:59 pm Post subject: Re: Need help creating batch file to create directory with t |
|
|
<foxj77@gmail.com> wrote in message
news:1145619404.915258.212790@u72g2000cwu.googlegroups.com...
| Quote: | Hi there,
I need to write a batch file to create a directory with the format
mm-yy. The script will be running on a windows 2003 server. The job
will be scheduled to run on a server every night.
I have an old one from a windows 2000 server but it doesn't work (and
it gives me the folder name in the format mm-yyyy). The code is below:
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET
datestring=%%b-%%c
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET monthstring=%%b
For /F "tokens=2-2 delims=/ " %%a in ('DATE /T') do SET YearToDo=%%c
d:
cd c
mkdir %datestring%
cd %datestring%
Can anyone help me out with this problem.
|
This will probably do:
@echo off
set datestring=%date:~4,2%-%date:~12,2%
md "c %datestring%"
cd /d "c %datestring%"
My own country code is different from yours, hence the format
of the command
echo %date%
on my machine may differ from the format on your machine.
If the result is not quite what you expect then shou should
play with the numbers 4 and 12 in line 2. They determine
which parts ("substrings") of the %date% variable are used. |
|
| Back to top |
|
 |
Fox1977 Guest
|
Posted: Fri Apr 21, 2006 4:20 pm Post subject: Re: Need help creating batch file to create directory with t |
|
|
Thanks,
When i run the script it creates a subfolder 4 with a folder within it
called '-'
c 4\->
Any tips? |
|
| Back to top |
|
 |
Pegasus (MVP) Guest
|
Posted: Fri Apr 21, 2006 4:33 pm Post subject: Re: Need help creating batch file to create directory with t |
|
|
"Fox1977" <foxj77@gmail.com> wrote in message
news:1145622020.172781.225910@v46g2000cwv.googlegroups.com...
| Quote: | Thanks,
When i run the script it creates a subfolder 4 with a folder within it
called '-'
c 4\-
Any tips?
|
Play with the numbers I suggested! |
|
| Back to top |
|
 |
|