Follow

@cwebber

> "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:

  1. 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
  2. use occur (usually bound to "M-s o") to narrow down the listed files in the Dired buffer , then use occur-edit-mode
  3. in the Occur buffer, use occur-edit-mode (bound to the "e" key) to make the occur buffer editable
  4. Use any number of query-replace ("M-%") or query-replace-regexp ("C-M-%") to rename any of the files in the Occur buffer.
  5. occur-cease-edit ("C-c C-c") to commit changes from the Occur buffer to the Dired buffer
  6. wdired-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.

· Edited · · Web · 3  · 8  · 14