Results 1 to 10 of 10

Thread: Creating a folder with sysdate

  1. #1
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Creating a folder with sysdate

    I am creating a batch file to take regular backups. In that batch file I have to create a folder with sysdate. How to do that can anyone suggest me?


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Creating a folder with sysdate

    save the script in fdate.bat
    DATE /t >dt.txt

    COPY tday.txt+dt.txt dat.bat

    CALL dat.bat

    SET today=%today: =%
    SET today=%today:/=%

    MKDIR C:\%TODAY%

    note: u have to create tday.txt,dt.txt,dat.bat


  3. #3
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Creating a folder with sysdate

    It is creating date in dt.txt correctly. It is showing following error message

    C:\>MKDIR C:\/=
    The syntax of the command is incorrect.


  4. #4
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Creating a folder with sysdate

    Quote Originally Posted by krishnaindia2007 View Post
    It is creating date in dt.txt correctly. It is showing following error message

    C:\>MKDIR C:\/=
    The syntax of the command is incorrect.
    In previous post where i used mkdir c:\/ ... ?
    u need to write all the below steps (6 steps) in fdate.bat and save it
    DATE /t >dt.txt
    COPY tday.txt+dt.txt dat.bat
    CALL dat.bat
    SET today=%today: =%
    SET today=%today:/=%
    MKDIR C:\%TODAY%

    and u need to create tday.txt,dt.txt,dat.dat files and save it in c:\


  5. #5
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Creating a folder with sysdate

    I have written all the six lines in the same batch file. while executing the batch file It is showing message
    C:\>MKDIR C:\/=
    The syntax of the command is incorrect.


  6. #6
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Creating a folder with sysdate

    Execute each statement separately in cmd and check it whether they are
    wroking in cmd correctly or not, becasuse bat file is executed correctly in my
    system. other wise use the simple command

    mkdir %date:/=%


  7. #7
    Junior Member
    Join Date
    Feb 2008
    Answers
    28

    Re: Creating a folder with sysdate

    hi
    @susarlasirisha

    can you explain your 6 steps...i am unable to understand why you created date in one file and copy that in another finally call that one. I am confused.

    DATE /t >dt.txt --This is ok
    COPY tday.txt+dt.txt dat.bat <i am strucked here>
    CALL dat.bat < now dat.bat has only one line . that too 'Date' not command, why did u call . this? >


    Jaya


  8. #8
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Creating a folder with sysdate

    try to use this in the batch file

    Code:
    for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set fdate=%%a%%b%%c
    for /f "tokens=1,2,3,4,5 delims=: " %%a in ('time /t') do set ftime=%%a%%b%%c%%d%%e
    
    exp userid=user_name/password@orcl  
    file=F:\Debasis\data\backup%fdate%%ftime%.dmp 
    log=F:\Debasis\data\backup%fdate%%ftime%.log



  9. #9
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Creating a folder with sysdate

    simply use this command

    md %date:~7,2%%date:~4,2%%date:~10,4%


  10. #10
    Junior Member
    Join Date
    Feb 2008
    Answers
    28

    Re: Creating a folder with sysdate

    hi all

    well it's working...thank you susarlasireesha


    what i understood is

    md %date:~7,2%%date:~4,2%%date:~10,4%

    is combination of 3 parts

    %date:~7,2% -> [For date]
    %date:~4,2% -> [For month]
    %date:~10,4% -> [For year]



    actually date give us Wed 02/20/2008

    toal 12 characters ( 0 to 11 )

    so in %date:~7,2% ..... 7 means starting position and 2 means number of characters. so it will take 2 characters starting from 7th position. that means date( here 20 )

    remaining two also same procedure.

    Jaya


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact