

Furthermore, we can easily find any e-mail held in the quarantine and check it further. We can now see when we caught some viruses in an e-mail. Here is an example of the folders (the ClamAV quarantine folder) sorted by date in their name: When we add the date string in such order, we can later sort the files and folders in ascending order, the day after day, in the chronological order. Then we can use it to create the directory per day or we can add it to the end of the file, like some log or the output result files. That string should be in format YYYYMMDD. We will then repack that information to one string for a today date. We can see that we have also slash sign (/) as the separator.

As we can see, we have three letter abbreviation of the name of the day, then we have space, the number of the month in the year, the number of the day in the month and finally the year by the Gregorian calendar. We will continue with first example, the US date format. This is the reason why we begin with 0 in the counter. First character in this string have a position of 0. We don’t need to count manually positions. Those numbers under the date string will be the position counter. I changed short date format to display the date on the way more common to the Serbian local settings. Here is another example of the changed local settings. When we run this batch file from the command prompt, we will see current date. Here is source of the check_date_format.bat file: off Those numbers will be used to mark a position of every number or the letter in the date string. I made a simple batch script that will just return the current date and under it write some numbers.
Command line find file and order by date windows#
I used all those scripts on the Windows XP, 2003 Server and later versions of the Microsoft Windows operating systems. With this method you will always have the same format of the current day or time, regardless the local regional settings. (Update ) You can find the alternate way to read the current date and time values in this post. That’s the reason why we need to check this settings before we can use any batch file that utilize the date value. Therefore, our batch file will work fine with one settings and return useless information with other.

The batch files can use special variable named DATE and which returns the current date in the local regional format.Īs we knew, the regional settings are different. We can use the value of current date (and also time) in the batch files, whenever we generating new files and folders. We can use, for example, the dates to distinguish the log files by the days. Using current date as part of the file or a folder (the directory) name is very useful.
