For example, if the user has been playing a lot of Tetris, could I check this through Python? Could it tell if a directory/file in Tetris game directory is being used?
Asked
Active
Viewed 1,249 times
2
-
I'm in Windows but hopefully all of them. I'm trying to make a treemap of directories/files with rectangle size representing the directory's size and color representing how often it's used – petabyte Jul 14 '12 at 00:07
-
@Jason: "All of them"? HughBothwell is right, this is highly dependent on which operating system you are using (i.e. the API calls you would do in windows are completely different from what you would do in linux). – Joel Cornett Jul 14 '12 at 00:10
-
Ah okay, I fixed the title to mean Windows – petabyte Jul 14 '12 at 00:17
2 Answers
1
One way to do this is keep track of all the file modification times at different time slices and run the program in a batch. You would then either keep track of all the times modified or the last modification and count of number of times it had been changed.
Check this out: How to get file creation & modification date/times in Python?
I don't know that Windows specifically keeps statistics on how many times a file has been used natively. but FWIW, there's some nasty VBScript code on TechNet that essentially does the same thing (here)
1
- Do you only need check the changed files? The watchdog can monitor all the changes in a folder. https://github.com/gorakhargosh/watchdog/ (it's a python project) In my understanding, it cannot detect the read-only options.
- Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx It can monitor all the FS operations and save it to a log file. You can try to parse the results via the python.

Xiongjia
- 11
- 1
- 2