Search code examples
emacsdired

dired list files sorted by access time


How can I list the output of this command

   ls -ltDR \`find . -maxdepth 4 -type f -name "*.org"\`  

within dired-buffer. The above command lists all org files sorted by access time.


Solution

  • First open dired buffer using M-x dired

    Sorting by access time in dired buffer

    You can change the sort command used to order the dired buffer.

    To sort by access time...

    C-u s

    this will bring up a minibuffer and you type -lutR

    The R will make dired recurse subdirectories

    Showing only .org files

    Following info from this thread here works:

    http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/acb20ee78c00e4ec#

    (Andreas Politz)

    Here is one way :

    1. Mark all files you want to see with `%m'
    2. Expression you need for .org files is ..org
    3. Inverse the marks via `*t'
    4. Invoke dired-do-kill-lines' withk'
    5. When done, Reset the listing with `g'

    Wrapped up in a function :

    (defun dired-show-only (regexp) 
      (interactive "sFiles to show (regexp): ") 
      (dired-mark-files-regexp regexp) 
      (dired-toggle-marks) 
      (dired-do-kill-lines)) 
    
    (define-key dired-mode-map [?%?h] 'dired-show-only)