You create and use batch files to automate different system administration tasks, such as backups, program and database updates or recording errors, when an application problems occur. DOS commands that are used in the batch files can include a variable, such as date and time. By using the string of the output from the date and time DOS commands you can create timestamps in the batch files to record time information during execution of system maintenance procedures.
- Skill level:
Other People Are Reading
Click "Start," "Notepad" to open Notepad editing program.
Click "File," "New."
Enter the following commands in the open window:
@echo off cls rem Timestamp Generator rem Parse the date (e.g., Fri 02/08/2008) set cur_yyyy=%date:~10,4% set cur_mm=%date:~4,2% set cur_dd=%date:~7,2% rem Parse the time (e.g., 11:17:13.49) set cur_hh=%time:~0,2% if %cur_hh% lss 10 (set cur_hh=0%time:~1,1%) set cur_nn=%time:~3,2% set cur_ss=%time:~6,2% set cur_ms=%time:~9,2% rem Set the timestamp format set timestamp=%cur_yyyy%%cur_mm%%cur_dd%-%cur_hh%%cur_nn%%
rem Do something with it echo Timestamp: %timestamp% rem Clear the environment variables set cur_yyyy= set cur_mm= set cur_dd= set cur_hh= set cur_nn= set cur_ss= set cur_ms= set timestamp=
Click "File," "Save." Enter "mybatchfile.bat" in the "Save As" box. Click "OK" to create the batch file with timestamps.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for