-
mkdir with date
This script works
echo off
@REM Seamonkey's quick date batch (MMDDYYYY format)
@REM Setups %date variable
@REM First parses month, day, and year into mm , dd, yyyy formats and
then combines to be MMDDYYYY
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%
%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%yyyy%%mm%%dd%
echo %date%
mkdir BEMRX-%date%
cd BEMRX-%date%
mkdir Source
mkdir CD
but I would to make the directory name the date then -BEMRX instead of
the way it is. When I try this
mkdir %date%-BEMRX
that makes two directories(one the date and one -BEMRX). Is there a
way to make that the name of the one
directory?
Thanks,
Tom
-
Re: mkdir with date
This line works fine for me:
mkdir %date%-BEMRX
it creates a single directory named "20070315-BEMRX". What is the format of
your %date%, is it the same as mine (YYYYMMDD)?
Also, %date% is a dynamic built-in variable. To avoid breaking other
scripts, you might want to use "SetLocal" in your script or use a different
variable name:
SET folderdate=%yyyy%%mm%%dd%
echo %folderdate%
mkdir %folderdate%-BEMRX
<tom.henricksen@gmail.com> wrote in message
news:1173967609.464689.23930@d57g2000hsg.googlegroups.com...
> This script works
>
> echo off
> @REM Seamonkey's quick date batch (MMDDYYYY format)
> @REM Setups %date variable
> @REM First parses month, day, and year into mm , dd, yyyy formats and
> then combines to be MMDDYYYY
>
> FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
> FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
> FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%
> %B
> FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
> SET date=%yyyy%%mm%%dd%
>
> echo %date%
>
> mkdir BEMRX-%date%
> cd BEMRX-%date%
> mkdir Source
> mkdir CD
>
> but I would to make the directory name the date then -BEMRX instead of
> the way it is. When I try this
> mkdir %date%-BEMRX
> that makes two directories(one the date and one -BEMRX). Is there a
> way to make that the name of the one
> directory?
> Thanks,
> Tom
>
-
Re: mkdir with date
On 15 Mar 2007 07:06:49 -0700, tom.henricksen@... wrote in
microsoft.public.windows.server.scripting:
>This script works
>
>echo off
>@REM Seamonkey's quick date batch (MMDDYYYY format)
>@REM Setups %date variable
>@REM First parses month, day, and year into mm , dd, yyyy formats and
>then combines to be MMDDYYYY
>
>FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
>FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
>FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%
>%B
>FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
>SET date=%yyyy%%mm%%dd%
>
>echo %date%
>
>mkdir BEMRX-%date%
>cd BEMRX-%date%
>mkdir Source
>mkdir CD
>
>but I would to make the directory name the date then -BEMRX instead of
>the way it is. When I try this
>mkdir %date%-BEMRX
>that makes two directories(one the date and one -BEMRX). Is there a
>way to make that the name of the one
>directory?
(I suspect your code creates a trailing space in %date%; try
echo %date%-BEMRX
and you should see what's going on.)
BUT, why so complicated? This does the same:
mkdir %date:/=%-BEMRX
(This works from CMD's command line; CMD requires different number of
%-signs in batch files; I forget exactly how - never use it.)
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
-
Re: mkdir with date
echo %date:/=% returns "Fri 03162007" for me, how do you remove the first 4
letters and still remove the /'s?
I tried adding "~4" after the colon but couldn't get the output I was
looking for.
example %date:~4% returns "03/16/2007", but I cannot find a way to also
include the /= to remove the /'s, any ideas? I suppose I could just do it
in two steps using a temporary variable but It'd be nice to not have to.
note: "~x,y" skips x characters and grabs y characters, if ",y" is not
specified, returns all remaining characters
"Michael Bednarek" <ROT13-zo@gtz.pbz.nh> wrote in message
news:k48kv2p7jd6f2mg2pgpv3fqg08ab7qkbdu@4ax.com...
> On 15 Mar 2007 07:06:49 -0700, tom.henricksen@... wrote in
> microsoft.public.windows.server.scripting:
>
>>This script works
>>
>>echo off
>>@REM Seamonkey's quick date batch (MMDDYYYY format)
>>@REM Setups %date variable
>>@REM First parses month, day, and year into mm , dd, yyyy formats and
>>then combines to be MMDDYYYY
>>
>>FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
>>FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
>>FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%
>>%B
>>FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
>>SET date=%yyyy%%mm%%dd%
>>
>>echo %date%
>>
>>mkdir BEMRX-%date%
>>cd BEMRX-%date%
>>mkdir Source
>>mkdir CD
>>
>>but I would to make the directory name the date then -BEMRX instead of
>>the way it is. When I try this
>>mkdir %date%-BEMRX
>>that makes two directories(one the date and one -BEMRX). Is there a
>>way to make that the name of the one
>>directory?
>
> (I suspect your code creates a trailing space in %date%; try
> echo %date%-BEMRX
> and you should see what's going on.)
>
> BUT, why so complicated? This does the same:
> mkdir %date:/=%-BEMRX
>
> (This works from CMD's command line; CMD requires different number of
> %-signs in batch files; I forget exactly how - never use it.)
>
> --
> Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
-
Re: mkdir with date
On Fri, 16 Mar 2007 13:09:04 -0700, Steven wrote in
microsoft.public.windows.server.scripting:
>echo %date:/=% returns "Fri 03162007" for me, how do you remove the first 4
>letters and still remove the /'s?
>
>I tried adding "~4" after the colon but couldn't get the output I was
>looking for.
>example %date:~4% returns "03/16/2007", but I cannot find a way to also
>include the /= to remove the /'s, any ideas? I suppose I could just do it
>in two steps using a temporary variable but It'd be nice to not have to.
>
>note: "~x,y" skips x characters and grabs y characters, if ",y" is not
>specified, returns all remaining characters
[snip]
CMD's environment variable DATE seems to be governed by Windows' "Short
date format". I suppose one could use a command line tool (REG.EXE) to
manipulate the registry on the fly to specify a suitable format; this
usually fails because a direct registry manipulation is not broadcast to
other applications.
The only truly generic method needs a language which provides access to
the elements which constitute a date; VBS/JS/4NT spring to mind.
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Page generated in 1,717,390,980.15777 seconds with 10 queries