I am trying to figure out how to apply a C program function to sort the file lists of the sub-folders inside my parent directory with modification date. For instance, if I have 12 files inside a directory called foo, I'd like to sort them by modification date and then remove the oldest 6. How should I approach this?
Asked
Active
Viewed 1,369 times
0
-
1`linux` / `windows` ? – kocica Aug 09 '17 at 10:58
-
do not use C for this, if you don't really have to! – yar Aug 09 '17 at 11:07
-
2write a `compar()` function for `qsort()`. – Aug 09 '17 at 11:08
-
1You can check [this](https://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c) for listing files in a directory, then check [this](https://stackoverflow.com/questions/9342789/how-to-get-file-modification-time-in-c-under-multiple-os) to get modification time of file and finally check [this](https://stackoverflow.com/questions/22003586/delete-files-from-a-specific-folder-in-c) to delete files. – Ketan Mukadam Aug 09 '17 at 12:43