Using python to filter files on disk -


I am using the below to extract the files from the disk.

  def match_files (Dior, Pattern): For files in DINN, Subdeer, OS Walk (DIR): For files in F: If F. Wandshut (pattern): produce OS path .join (dirname, f) # Remove all files in existing die matching * Match_files (dn, '.txt') for f.txt: os.remove (f)   

I would like to remove the files from the disk that "was not updated today." Check to list files from today to update the list.

In addition to osstat you can use os.path Getmtime or os.path.getctime , where the pro / Conn are discussed. You can use datetime.datetime.fromtimestamp to convert the timestamp returned in the datetime object, and then you can do whatever you like. In this example, I will not edit the files today, will create a list of the remaining files: . Date () Balance = [] Match_files (dn, '.txt') for f: mtime = datetime.fromtimestamp (os.path.getmtime (f)) date () if mtime! = Today: os.remove (f) Other: remaining.append (f)

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

memcached - Django cache performance -