On Nov 17, 9:06 pm, "Dean Wells \(MVP\)"
<dwe...@maskmsetechnology.com> wrote:
> That won't function; delayed expansion is sadly not a default behavior.
>
> --
> Dean Wells [MVP / Directory Services]
> MSEtechnology
> [[ Please respond to the Newsgroup only regarding posts ]]
> R e m o v e t h e m a s k t o s e n d e m a i l
>
> "Matt Williamson" <ih8s...@spamsux.org> wrote in message
>
> news:473b4f73$0$26481$(E-Mail Removed)...
>
> >> Using Windows XP or Win 2003 Server.
> >> Is there a way to make a batch file that will create a new folder
> >> with the date?
>
> >> For example, if it were this easy....,
> >> MKDIR %DATE% would make a directory 11-13-2007
>
> > This is heavily dependent on your regional settings. What do you get
> > when you echo %date%? There are many ways to do it, but the most
> > appropriate way is to code for any possible date format. This requires
> > a lot more code though and is only necessary if you need to do it on
> > many systems with different regional formats. I generally do it this
> > way using a short date format of mm/dd/yyyy.
>
> > set dt=%date:/=-%&md %dt%
>
> > which just takes the input of %date% which is "11/14/2007" and
> > replaces any "/" with "-" to make it compatible with the characters
> > windows accepts to create a folder.
>
> > HTH
>
> > Matt
>
> > --
> > Posted via a free Usenet account fromhttp://www.teranews.com
Nor does it remove the day-name that %DATE% returns, even if it is
done as successive statements. Though it is a better way to remove
the problematic hyphens for the stated reason of locale independance.
Working with Mr. Williamson's approach I was able to find this
adaptation that does NOT need delayed expansion ...
for /f "tokens=2" %a in ("%date:/=-%") do md %a
It solves both problems and remains one (rather complicated) statement
at the command line - or a single statement in a batch procedure when
the percent signs are doubled.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/