I have a folder that has many DWG files and an example of some files might be
LINCOLN 09-17 #1-29H ASBUILT 10-26-2010.dwg
LINCOLN 09-17 #1-29H FINAL 01-20-2011.dwg
CAMPBELL 07-17 #5-29H DRAFT 01-20-2011.dwg
CAMPBELL 07-17 #5-29H FINAL 01-27-2011.dwg
CAMPBELL 07-17 #5-29H FINAL 01-27-2011_1.dwg
I would need to capture (maybe in a list?) only the dwg files that have FINAL and are the latest modified dwg file for that file name. So the files above that would be captured are
LINCOLN 09-17 #1-29 FINAL 01-20-2011.dwg
CAMPBELL 07-17 #5-29H FINAL 01-27-2011_1.dwg
Any suggestions?
Moderator, I cannot seem to add comments to the questions below. Why is that??
Here is what I have so far.. I placed comments where I think I need changes
import os
rootdir='c:\Your\Path'
for subdir, dirs, files in os.walk(rootdir):
for file in files:
# I need to check only files with the same name so I can
# get the latest of those files before checking next files
if os.path.getmtime(file):
# I believe this will get time file was modified but
# but how do I store this to compare to other files
# with this name??