Created
October 13, 2015 01:42
-
-
Save tkhoa2711/a09039571b0ac437758f to your computer and use it in GitHub Desktop.
Find the last modified file within a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun last-modified-file (parent-dir &optional pattern) | |
"Get the last modified file under `parent-dir'. | |
A regex `pattern' can be provided to only look for those that match." | |
(let ((default-directory parent-dir)) | |
(first | |
(sort | |
(directory-files default-directory 'absolute pattern 'nosort) | |
(lambda (x y) | |
(time-less-p (nth 5 (file-attributes y)) | |
(nth 5 (file-attributes x)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment