How would I have the time a folder is saved added to the date saved in the attached code?

Posted on 2011-05-11
Last Modified: 2012-05-11
I have attached code from a cmd file that I run via task manager to save a folder named with the date saved.
What would I add to the "set folder=" line so that the folder is named with the date and "time" saved. Thanks
@echo off
set drive=F:\Backup
set folder=eDIGS_%date:~10,4%_%date:~4,2%_%date:~7,2%
set backupcmd=xcopy/s/c/d/e/h/i/r/y

md "%drive%\%folder%"

@echo %backupcmd%  "C:\shared$\eDIGSNEW"  "%drive%\%folder%"
%backupcmd%  "C:\shared$\eDIGSNEW"  "%drive%\%folder%"

echo Backup Complete!

Open in new window

Question by:PDSWSS
    LVL 38

    Expert Comment

    by:Aaron Tomosky
    set h=%TIME:~0,2%
    set m=%TIME:~3,2%
    set s=%TIME:~6,2%
    set time=%h%_%m%_%s%

    Author Comment

    How would I add to the line below:

    set folder=eDIGS_%date:~10,4%_%date:~4,2%_%date:~7,2%
    LVL 38

    Accepted Solution

    I'd split it up like so:

    set day=%date:~10,4%_%date:~4,2%_%date:~7,2%
    set h=%TIME:~0,2%
    set m=%TIME:~3,2%
    set s=%TIME:~6,2%
    set time=%h%_%m%_%s%

    Easier to read this way

    Author Closing Comment

    Perfect answer. Thank you very much.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
    VM backup deduplication is a method of reducing the amount of storage space needed to save VM backups. In most organizations, VMs contain many duplicate copies of data, such as VMs deployed from the same template, VMs with the same OS, or VMs that h…
    This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
    This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now