Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been trying to work out out how to delete the oldest file in a directory of files. This is what I came up with and wanted to see if anyone has a better idea. This can perform rather slow when the directory has nearly 5000 files.
(setq test (vl-directory-files "C:\\Autocad\\temp" "*.*" 1))
(while (> (length test) 1)
(if (>
(vl-file-systime (strcat "C:\\Autocad\\temp\\" (nth 0 test)))
(vl-file-systime (strcat "C:\\Autocad\\temp\\" (nth 1 test)))
)
(setq test (cdr test))
(setq test (append (list (car test)) (cddr test)))
)
)
(vl-file-delete (car test))
Civil 3D 2022,
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2
Windows 10 Pro, x64, Nvidia Quadro P1000
Intel Core i9-11900k; 3.50GHz, 32 GB RAM, 500GB WD BLACK M.2
Solved! Go to Solution.