How to Create Date and Time Stamp in Batch Files?
- 2016-08-16 04:48:16
Microsoft windows operating system has the ability to process commands through a batch file. A batch file contains the commands in form of text, it joins together a set of commands into one file. Later on those commands are executed by the help of command interpreter. Windows operating systems uses DOS to communicate to hardware and DOS uses command interpreter to create a communication bridge between the Windows operating system and hardware. You can generate date and time stamps in batch file, this way you will be able to automate your commands executed in a pattern and time desired. DIR command can be used to bring up the available files and subdirectories.
Create a Batch File with Filename and Timestamps
Here is how a batch file shows all files, folders, subfolder and their subfolder files with time and date created and modified timestamps, and will be saved as a .txt or xls file.
This is the order below which specifies the drive, directory and file to the list.
•/A- Shows files with specific attributes, attributes D Directories R Read-only files
• H - Hidden files, A Files ready for archiving
• S - System files - Prefix meaning
•/B - Uses bare format contains no heading information or summary
•/C - Shows the thousand separator in file sizes. This is the default. Use /-C to disable display of separator
•/D - Same as wide but files are sorted in a list by column
• /L - Uses lowercase
• /N - New long list format where filenames are on the right side
• /O - List by files in sorted order. Sort order N By name (alphabetic) S By size (smallest first)
•E - By extension (alphabetic) D By date/time (oldest first)
•G - Group directories first - Prefix to reverse order
•/P - Pauses after each screen full of information
•/Q - Display the owner of the file
•/S - Displays files in specified directory and all subdirectories
•/T - Controls which time field displayed or used for sorting. Time field C Creation
•A - Latest Access
• W - Latest Written
• /W - Uses wide list format
• /X - This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is shown, blanks are displayed in its place
•/4 - Displays four-digit years
DIRCMD environment variable may contains switches. Override preset switches are represented by hyphen (-) example, /-D