(Jan-11-2017, 06:09 PM)snippsat Wrote: Here are some hints.Thank you for your effort, but as I already wrote (I know I wrote large text, hard to follow):
You can probably use getmtime(path),
Return the time of last modification of path/file.
Quote:Just deleting anything older then (current date - x days) is not viable because if some file has not changed in that time, all versions (but current backup) will be deleted.Versioning files appear only if there was a change. If last change of certain file was a year ago, then deleting anything older then a month would also delete every single versioning file, leaving only same file as user/client has on his PC.
So to keep at least one versioning file, it is imperative to parse the text and pull out:
1. original filename
2. date and time from the name itself
Which answers I need, as far as I understand:
a) I need to sort the list of files based on original name and date time (string operations), newer first
b) Outside of the sorted() I need to scroll through sorted list and using same string tools from a) and leave/skip only first two for each original file, deleting the rest.
c) Can someone provide me at least with proper format of "def" definition (with return?) so I can use it as a base? I understood that I need to use "key" function. This is the hardest part to understand.