Batch file is one of the most useful tools in server performance monitoring or even some simple command execution. It simplify our job as we can always schedule a batch file to run under Windows Task Scheduler.
Of the the most obvious example is that you need to backup an output file to an achieve folder, you do not need a complicated program compiler like Microsoft Visual Basic or Visual Studio .NET to do the job. What you need is just a simple batch file that will copy the output file to a new location and rename it with today’s date or other prefix date format.

Display of date format in batch file

When i was just start to write a batch file, it took my quite a couple of minutes to figure out how to rename the text file with the date format i required. If you have the same problem as mine, below is the answer.
You can try it by opening our command prompt under your windows program file -> accessories -> command prompt.

If you type “echo %date%” in your command prompt, it will display today’s date by following your regional setting (“Mon 03/09/2007” for example).
What you need to do in order to display the date in format of yyyymmdd? Ok, what you need to do is just type “echo %date:~10,4%%date:~4,2%%date:~7,2%”, it will now display today’s date in yyyymmdd format (“20070309” in this example), and you can always manipulate the date format you desire by just changing its sequences.

If you would like it to display as ddmmyyyy, it shall be “echo %date:~4,2%%date:~7,2%%date:~10,4%”, simple isn’t it?

Technorati Tags : Command Prompt, Script, Windows

Popularity: 19% [?]

Technorati Tags: , ,

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • description
  • ThisNext
  • MisterWong
  • Wists
  • Netscape
  • Reddit
  • StumbleUpon
  • Technorati

If you're new here, you may want to subscribe to my FULL RSS feed. Thanks for visiting!

Related Post:
  • 2 Simple Ways to improve Vista Performance
  • Reinitialise Microsoft Windows with SysPrep
  • Windows Vista ReadyBoost - Personal Experience
  • My first trial on Windows Live Writer…
  • Windows Live Writer…I love it


  • Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>