TIP: semi-bulk changing the extension of file names in dired
Steinar Bang <[email protected]>
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
I started using emacs in 1987, and I still keep discovering new useful
features.
In my react frontend apps I have, since the start in 2018, been using
the .js extension on both JSX and plain js files. And since then it has
seemed like too much renaming work to split the two.
But with vite 8.0.0 it sounds like the simplest solution is actually to
bite the bullet and rename all JSX files to .jsx.
The problem for the renaming is that the files that are to be renamed to
.jsx is mingled with files that should stay as .js files. So doing this
with a shell script or command line is more work than it is worth.
So I googled, and the built-in solution in emacs proved to be amazingly
simple and user friendly:
1. Open dired on a directory containing jsx files
2. Type 'C-x C-q' to make the dired buffer writable
3. Edit the file names in the dired buffer directly (in my case: add an
"x" to the end of the file names that are supposed to have it)
4. Type 'C-c C-c' to commit the changes
Here is the relevant manual entry: https://www.gnu.org/software/emacs/manual/html_node/emacs/Wdired.html