Jump to content

Simple batch date operation (backup files).

- - - - -

  • Please log in to reply
3 replies to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Hello,
First off i'm a C++ programmer so know little about Batch files (I understand how to run them and stuff) so I might need some pretty beginner stuff, second of all I have Googled for this.

I have a batch file that starts my server, however before I do this I want to make a backup complete with the date. Something like this:
backups/StartBak.%m.%h.%d.%M.%y
(minute, hour, day, Month, year)
I use xcopy to copy the folder but I am stuck with getting the time/date values... I understand variables from my little batch experience (besides variables are fundamental so there should be plenty on Google) so that wont be a problem.

So does anyone know basic operations such as setting a variable to the current minute?
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2
fayyazlodhi

fayyazlodhi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 403 posts
I guess you need the "date" command on windows shell

Here is sufficient info
Batch files - DATE and TIME

Basically i googled for batch files / cmd.exe commands etc.

Edited by fayyazlodhi, 20 June 2011 - 11:49 AM.
Fixing the copied link

Today is the first day of the rest of my life

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
It is more hard to do in NT batch (you can see many examples online with padding substring and whatnot.)

If you use Windows 7 or Server 2008 the Powershell has a date and time class.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Errr I found that webpage, it confused me :(.
I'm running Vista...
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users