0

I am fairly new with creating batch files.

I have made a batch file with the following content:

"C:\Program Files (x86)\Runtime Software\DriveImage XML\dixml.exe" /bC /c /l /t"B:\DRIVE IMAGES\Windows10_maintenance_backup

This allows me to run DriveImage XML and take a backup simply by running the bat file.

I would like the bat file to automatically make a folder with today's date so that:

B:\DRIVE IMAGES\Windows10_maintenance_backup

Becomes:

B:\DRIVE IMAGES\2016.01.20\Windows10_maintenance_backup

How can I achieve this by editing the .bat file? I have had a look at foxidrives solution here but I do not know how to implement the solution.

Community
  • 1
  • 1
Arete
  • 948
  • 3
  • 21
  • 48
  • 2
    This question was previously answered with a method that is region independent. http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us – RLH Jan 20 '16 at 23:14
  • Unfortunately it won't work on all computers. `WMIC` needs to be run by an administrator before a normal user can use it. –  Jan 21 '16 at 00:00
  • 1
    vMax's solution from that page is the one I would use. You assumed the checked one. – RLH Jan 21 '16 at 00:26
  • Yeah, I just used vMax solution and it works. I would like to show the final result but now the post is marked as a duplicate so I don't know if I should. – Arete Jan 21 '16 at 12:06

1 Answers1

1
echo    md B:\DRIVE IMAGES\%date:~-4%.%date:~7,2%.%date:~4,2%\windows10\etc

See set /? for help on substring extraction.

This assumes date is in following format

Thu 21/01/2016

  • What does md stand for? – Arete Jan 21 '16 at 00:19
  • it's the make directory (`md` or `mkdir`) command, I am echoing so they can see the command without actually executing it. See `md /?` and `echo /?`. Also type help. –  Jan 21 '16 at 00:25
  • Sorry this did not work at all. I have no idea how to implement this in the following line: `"C:\Program Files (x86)\Runtime Software\DriveImage XML\dixml.exe" /bC /c /l /t"B:\DRIVE IMAGES\Windows10_maintenance_backup` – Arete Jan 21 '16 at 11:56