[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

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

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
::variables
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!
@pause

Open in new window

0
PDSWSS
Asked:
PDSWSS
  • 2
  • 2
1 Solution
 
Aaron TomoskyTechnology ConsultantCommented:
set h=%TIME:~0,2%
set m=%TIME:~3,2%
set s=%TIME:~6,2%
set time=%h%_%m%_%s%
0
 
PDSWSSAuthor Commented:
aarrontomosky:
Thanks,
How would I add to the line below:

set folder=eDIGS_%date:~10,4%_%date:~4,2%_%date:~7,2%
0
 
Aaron TomoskyTechnology ConsultantCommented:
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%
folder=eDIGS_%day%_%time%


Easier to read this way
0
 
PDSWSSAuthor Commented:
Perfect answer. Thank you very much.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now