In this tutorial I show how to get substrings from environment variables in a DOS shell or Command Prompt environment. We use this to create log files with that days date in the file name using batch scripts. We will then create a script that can be scheduled to defrag a computers drives and output the results to the log file we specify.