Results 1 to 5 of 5

Thread: mkdir with date

  1. #1

    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


  2. #2
    Marty List Guest

    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


    <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >



  3. #3
    Michael Bednarek Guest

    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"

  4. #4
    Steven Guest

    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" <[email protected]> wrote in message
    news:[email protected]...
    > 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"




  5. #5
    Michael Bednarek Guest

    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"

Similar Threads

  1. Baseline Column Date automatically updates Finish Date
    By Adam 1980 in forum Microsoft Project
    Replies: 3
    Last Post: 18-05-2011, 06:08 PM
  2. Implementation of mkdir() : C
    By Agustíne in forum Software Development
    Replies: 4
    Last Post: 02-02-2010, 06:16 PM
  3. Mkdir with variable space
    By Kingfisher in forum Software Development
    Replies: 5
    Last Post: 19-12-2009, 11:55 AM
  4. Error mkdir() in PHP
    By GlassFish in forum Software Development
    Replies: 3
    Last Post: 28-11-2009, 10:33 AM
  5. Changing start date and creating formula for finish date
    By stringse in forum Microsoft Project
    Replies: 1
    Last Post: 11-09-2006, 01:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,567,750.38735 seconds with 16 queries