

Also, a file created in the current directory with the name “access_20171102-154136.log” (Filename will be according to current date and time and will change during your testing) Conclusion You will find that a directory is created with the name “20171102-154136”. Open a terminal and execute the above batch script. Set SUBFILENAME=%CUR_YYYY%%CUR_MM%%CUR_DD%-%CUR_HH%%CUR_NN%%CUR_SS% To test this create a file test.bat with the following content. The complete windows batch script will look like below. If your current date time is 15:41:36, then the above example will create a file in the current directory with name “access_20171102-154136.log”. You can use and create any file name as per your requirements like: set SUBFILENAME=%CUR_YYYY%%CUR_MM%%CUR_DD%-%CUR_HH%%CUR_NN%%CUR_SS%Įcho "Welcome Here!" > access_%SUBFILENAME%.log Now, you have variables having current date and time in variables. Now extract the hours, minutes, seconds, and microseconds and store them in variables. Next is to parse the time which is available in 15:41:36.39 (Hours, Minutes, Seconds, and Micro Seconds) format. So use following commands to extract the date in YYYY format, month in MM format and date in DD format and stored in CUR_YYYY, CUR_MM, and CUR_DD variables correspondingly. Windows takes the date in the format like Thu. Let’s go through the tutorial and understand the process to accomplish this.
