0

I want to get all the full path by a folder name called autoload, in my config i had split it like this file structure.

├── init.el
├── packs
│   ├── +completion
│   │   ├── ivy
│   │   │   ├── autoload
│   │   │   │   ├── evil.el
│   │   │   │   ├── hydras.el
│   │   │   │   └── ivy.el
│   │   │   └── config.el
│   ├── +editor
│   │   ├── fold
│   │   │   ├── autoload
│   │   │   │   ├── fold.el
│   │   │   │   └── hideshow.el

so i want get all autoload folders path list, this function will return a list like ("/User/xxxx/.emacs.d/packs/+completion/ivy/autoload/","/User/xxxx/.emacs.d/packs/+editor/fold/autoload/"). thanks!

  • So you want all directories under a given directory that are at a given depth? Something like what find /User/xxxx/.emacs.d -mindepth 3 -maxdepth 3 -type d would do? – NickD Sep 12 '19 at 14:29
  • just to given a folder like eva-packs-dir . i had define eva-packs-dir – xiaodong huan Sep 12 '19 at 14:40
  • I'm sorry, I don't understand what you mean. Does the find command above give you what you want (I know it's not emacs, but I'm just trying to understand your requirements)? Perhaps @rpluim's answer below does what you want? – NickD Sep 12 '19 at 15:22
2
(cl-remove-if-not #'file-directory-p (directory-files-recursively "name-of-directory" "autoload" t))

directory-files-recursively seems not well-known for some reason. See Directories for a fuller explanation.

  • That will find subdirectories at every level, correct? Maybe that's what the OP wants, maybe not: the question is not clear on that point. – NickD Sep 12 '19 at 15:19
  • Every level, yes. Salt with (length (split-string file "/" t)) to check the depth. – rpluim Sep 13 '19 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.