Need help creating batch file to create directory with the d
 




IT Certification FAQ

 
|
Home
|
Microsoft
|
CISCO
|
CompTIA
|
Exam/Study FAQ
|
Employment FAQ
| Links  | Forums  |
Book Reviews


FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  ProfileProfile  Log in to check your private messagesPrivate messages  Log inLog in

Need help creating batch file to create directory with the d

 
Post new topic   Reply to topic    Forum Index -> microsoft.public.windows.server.general
Author Message
Guest






PostPosted: Fri Apr 21, 2006 3:36 pm    Post subject: Need help creating batch file to create directory with the d Reply with 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 cdisgusted
mkdir %datestring%
cd %datestring%

Can anyone help me out with this problem.
Back to top
Pegasus (MVP)
Guest





PostPosted: Fri Apr 21, 2006 3:59 pm    Post subject: Re: Need help creating batch file to create directory with t Reply with quote

<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 cdisgusted
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 "cdisgusted%datestring%"
cd /d "cdisgusted%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





PostPosted: Fri Apr 21, 2006 4:20 pm    Post subject: Re: Need help creating batch file to create directory with t Reply with quote

Thanks,

When i run the script it creates a subfolder 4 with a folder within it
called '-'

cdisgusted4\->

Any tips?
Back to top
Pegasus (MVP)
Guest





PostPosted: Fri Apr 21, 2006 4:33 pm    Post subject: Re: Need help creating batch file to create directory with t Reply with quote

"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 '-'

cdisgusted4\-

Any tips?


Play with the numbers I suggested!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> microsoft.public.windows.server.general All times are GMT
Page 1 of 1

 

Copyright © 2002-2006 Web-S-Sense Pty. Ltd. All rights reserved.

Powered by phpBB
Advertising | Policies/Disclaimers | Contact us | Link to us


Featured Sites: Free Antivirus and Antispyware Info | Free PC Support | MCSE Directory