Change all of the file names in a Directory with Emacs
- Turn on transient mark mode
- Find directory and open it with Dired
- Put directory in editable Mode
To Add the desired text
Select the region that you want to edit
If you want to add a word in front of all files then create mark
C-<space>in front of first file name and move to position of last file and create mark
C-<space>in front of file name.
Go into Rectangle Insert mode
C-x r t. Emacs will prompt for the string you want to add, type it in and hit enter.
If you’d like to remove a space in file names
Select region that you want to delete
If you want to remove a space in between words in all files then create a mark
C-<space>in front of first space in the first file and move to position of last file name and go to the end of the space and create a mark
call the Rectangle Kill command
C-x r k. Emacs will remove the space in all of the file names. If the region was incorrect you can undo the change with
C-x uand start again.
Exit editable dired mode to save changes
Back to Reality
Once you are satisfied with your changes exit editable directory mode to save changes with:
|C-x C-d||Find Directory in Dired Mode|
|C-x C-q||Make direcory editable|
|C-c C-c||Save changes, return to normal mode (if in edit mode)|
Rectangle Edit Mode
Note: first select region by making mark. The rectangle will be the columns from the start mark to the end mark. If in transient mode, the highlighted region will highlight all columns in all rows, but if you start on column 1 and end on column 3, then the selected rectangle is only the first 3 columns in each of the selected rows.
|C-x r t||insert into rectangle|
|C-x r k||kill/delete rectangle|
|C-x r y||yank/copy register into rectangle|
|C-x r N||insert ascending numbers into rectangle|