Follow
> "I knew M-x occur was awesome, and I already used it a lot, but I learned" ...> ... "e: enable editing definitions directly from the *Occur* buffer!!!!"
Oh it gets even better. Try this one out:
dired-toggle-read-only
(usually bound to "C-x C-q
"), now the Dired buffer is editable — you can change the names of files and later choose to commit those changes to disk- use
occur
(usually bound to "M-s o
") to narrow down the listed files in the Dired buffer , then useoccur-edit-mode
- in the Occur buffer, use
occur-edit-mode
(bound to the "e
" key) to make the occur buffer editable - Use any number of
query-replace
("M-%
") orquery-replace-regexp
("C-M-%
") to rename any of the files in the Occur buffer. occur-cease-edit
("C-c C-c
") to commit changes from the Occur buffer to the Dired bufferwdired-finish-edit
(also bound to "C-c C-c
") to commit those changes in the Dired buffer to the filesystem.
In my opinion, this is probably the safest, most reliable way to do bulk file renaming.
I use this workflow quite often, especially when preparing datasets for machine learning processes. #Emacs