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

Inserting a date into a file name

Options
  • 02-04-2005 1:30pm
    #1
    Registered Users Posts: 520 ✭✭✭


    Hi
    This probably has a simple answer. I have a .bat file to do backups.

    "EXP Promet/wendle@WG4_DB File = D:\Prometheus\Backup\BACKUP10-3-2005.DMP Log = D:\Prometheus\Backup\BACKUP10-3-2005.LOG Compress = Y "

    I want this to automatically put current date into the name of the .dmp & the log file. Up to this I have been manually editing the bat file every time I want a new backup. There must be an easier way so I can automate the process.

    Thanks in adv


Comments

  • Registered Users Posts: 6,508 ✭✭✭daymobrew


    There are some posts within the last few months that dealt with batch files and relatively fancy stuff you can do with them.

    If you used some Unix tools (e.g bash, date) you'd be able to do this very easily. (See Cygwin)

    Looking up CMD help (cmd /?) I got something that might be a start:
    FOR /F "usebackq delims==" %i IN (`date /t`) DO set NOW=%i
    echo %NOW%
    // Returns 02/04/2005. Formatting probably due to my date locale settings.
    
    Changing the code slightly: (changing delims)
    FOR /F "usebackq delims==/" %i IN (`date /t`) DO set NOW=%i
    echo %NOW%
    // Returns 02.
    
    I would say that it is time to look up Google Groups


Advertisement