Skip to main content

How to find the last modified file ?

It may be straightforward to find the last modified file in a given folder, but what if I wish to find the last modified file from among a group of folders, or from all the sub directories in a folder.

Here is my solution which makes use of the following two things:
* Command prompt (to get there in Windows, press Window key + R and type cmd)
* Any spreadsheet program like MS Excel, OpenOffice Calc etc.

Step 1:
 At the command prompt, use the DIR command to generate the list of files that you wish to search among. It is important that the command returns a list of files with the date of modification column included. 
Use the > operator to write the output to a file.

Example: DIR C:\myfolder\*.c /s /t:w > dir.txt

The above command, lists all the C files in the C:\myfolder directory and its subdirectories and creates a file dir.txt in the current working directory and writes the output into it. The /t:w switch makes sure that the date and time stamp is that of the last written date. Use /t:a, /t:c instead for last access, creation dates respectively.

Step 2:
Copy and paste from the above file into the spreadsheet program. A dialog box should pop-up asking to split into columns. Use fixed width delimiter and separate out the date and time stamps into separate columns.

Step 3:
Sort with the rule: date stamps first and then time.

Reference:

Comments

Popular posts from this blog

Competitive Programming

Programming a Sport ? I didn't know that until today !! I was amazed to look around and find that so many initiatives abound on the internet that aim at popularizing programming. I got started at codechef.com , then watched an amazing inspirational video http://www.codechef.com/school The getting started page launched me into a web of great resources - http://www.codechef.com/getting-started Check every link ! I met two great heros of the sport in that great journey - 'tourist' and 'petr' The latter is elder to me while the former is just 19 now. petr works for Google but is still a great force in the sport. The ACM ICPC is like the olympics of programming where teams participate. Codechef's envision's the Indian team winning some day and the Go-for-Gold section is particularly geared towards that. Codechef also has a school section. Mathewkuttan, Maxwell - what do you think ?