Elisp: File and Directory Functions
Here's the most useful functions for file and directory.
Functions on File
rename-file
-
(rename-file "~/test1.txt" "~/test2.txt")
copy-file
-
(copy-file "~/test1.txt" "~/test2.txt")
delete-file
-
(delete-file "~/test2.txt")
make-empty-file
set-file-modes
Creating Temp File with Unique Names
make-temp-file
temporary-file-directory
Functions on Directory
directory-files
-
List files. 〔see Elisp: Walk Directory, List Files〕
make-directory
-
Create a directory.
delete-directory
-
Delete a whole dir.
new in Emacs 23 (Released 2009-07)
(delete-directory "~/stuff" t)
copy-directory
-
(copy-directory "~/stuff" "~/stuff-backup")
other. unsorted
these are less used.
- Variable: inhibit-file-name-operation
- Function:
find-file-name-handler
- Function:
file-local-copy
- Function:
file-remote-p
- Function:
unhandled-file-name-directory
- Function:
file-local-name
- User Option: remote-file-name-inhibit-cache
- Variable: format-alist
- Variable: buffer-file-format
- Command:
format-write-file
- Command:
format-find-file
- Command:
format-insert-file
- Variable: buffer-auto-save-file-format
- Variable: write-region-annotate-functions
- Variable: write-region-post-annotation-function
- Variable: after-insert-file-functions
file-chase-links
file-equal-p
file-name-case-insensitive-p
vc-responsible-backend
file-newer-than-file-p
file-has-changed-p
file-attributes
file-nlinks
file-acl
file-selinux-context
file-extended-attributes
locate-file
executable-find
Reference
Elisp, File, Buffer
- Elisp: Buffer Functions
- Elisp: Read File
- Elisp: Read File Content as String or Lines
- Elisp: Write File
- Elisp: Open File, Read, Possibly Write
- Elisp: File and Directory Functions
- Elisp: Get File Info
- Elisp: File Path Functions
- Elisp: Walk Directory, List Files
- Elisp: Walk Directory by Depth 🚀
- Elisp: Get Dired Marked Files