Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5842695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:03:04+00:00 2026-05-22T12:03:04+00:00

I have a folder that has many DWG files and an example of some

  • 0

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??
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:03:05+00:00Added an answer on May 22, 2026 at 12:03 pm

    You need to go searching for the suitable files, and remeber the newest of each one as
    you come accross it. Then report the latest.

    In pseudo-code.

    dates = dict() // key is filename, value is date
    for  subdir,dirs, files in os.walk(startdir):
    if filename ends with "dwg":
         if filename contains "FINAL":
              date = getDate from filename 
              if dates contains filename
                  prev = dates(filename)
              else 
                  prev = zero date // a value so next line tests true always
              if date > prev:
                 dates(filename) = date
              // else previous is younger, so skip
        // else draft or as built and skip
    // else filename not dwg and skip
    for dates.values as v
        print v
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a folder on my remote server that has a few .png files
I have a folder in my WPF app Images that has several .png files
I have a folder on my web server that has hundreds of mp3 files
I have a folder that contains many different files: folder1: somthing.php somthingelse.php blah.php ect
I have a folder which has many files. Files are continually being dropped into
Can anybody guide me in the right direction... I have some folder strucktures that
I have a table that has a one to many relationship with itself. Each
In my site I have many folders that holds different type of files. /img/
I have a set of folders that has a depth of at least 4
If I have a folder structure that looks like this: / /bin/myComponent.cfc /reports/index.cfm How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.