Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

2003 cmd file help

Options
  • 29-01-2006 4:29pm
    #1
    Registered Users Posts: 902 ✭✭✭


    howdy all, ill make this quick, basically I'm trying to make a directory using the curent time and/or date for log files to be stored in.
    This is what I want to happen

    1. the script does it job, and then creates log files on several servers
    2. a logs folder is created from where the script is run
    3. at the end of the script it robocopies all the logs from the servers to the logs folder at one location from where it was run.

    The only problem I'm having is the syntax in creating the folder on Server 2003.

    On my XP workstation I used md h:\steve\%date% and it created h:\steve\29-Jan-06

    On W2003 it errored: The syntax of the command is incorrect.

    Eventually I used: md f:\sync\logs\"%date%" and this worked but it created the following directory structure: F:\sync\logs\Sun 01\29\2006 where I only want one sub-folder under logs...

    Any help would be greatly appreciated
    - Steve


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Two options.

    1) Store the date to a variable first, and parse through it changing all / to -
    2) Change the date formatting options on your servers Control Panel in the Regional and Language Options.


  • Registered Users Posts: 902 ✭✭✭thesteve


    Thanks for the speedy reply!
    2) Change the date formatting options on your servers Control Panel in the Regional and Language Options.
    if only I had the rights...

    I'll read up on option number one, my batch file skills are basic, parsing is not something I've done before...

    Thanks again


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 90,813 Mod ✭✭✭✭Capt'n Midnight


    SET /? to see some options

    echo %DATE:~0,2%-%DATE~:3,2%-%DATE:~6,2%


  • Registered Users Posts: 1,275 ✭✭✭bpmurray


    Or, similarly:

    for /f "delims=/ tokens=1-3" %%a in ("%DATE%") do (
    set FILENAME=basename-%%c-%%b-%%a
    )
    echo %FILENAME%


Advertisement