An Emacs 'Killer Feature' Is Bulk Renaming

preview_player
Показать описание
One of the problems that will occasionally crop up from time to time on Linux is the need to do a bulk rename of files/directories. And there really aren't many simple solutions for this. Typically, a bulk rename involves piping together a few shell commands. But one program makes bulk renaming a breeze...EMACS!

WANT TO SUPPORT THE CHANNEL?

DT ON THE WEB:

FREE AND OPEN SOURCE SOFTWARE THAT I USE:

Your support is very much appreciated. Thanks, guys!
Рекомендации по теме
Комментарии
Автор

The art is to remember next time how you did it last time.

ernstmayer
Автор

0:28 this is not true at all. Nautilus can bulk rename with ease. Select a bunch of files by shift-clicking or dragging, then press F2 rename. Works flawlessly.

helloimatapir
Автор

What may not be obvious is you can also use regex or Emacs macros in more complex renaming scenarios or even write some custom Elisp. Essentially, placing a Dired buffer into edit mode treats it like a mostly normal buffer so all editing capabilities are available. In native Emacs keybindings, if you activate cua-selection-mode then you can press C-Return to enter rectangle column edit mode very similar to evil visual block mode. The complete cua-mode is not required to use cua-selection-mode. I have it turned on all the time as it doesn't conflict with other keybindings like full cua-mode will. It also gives you multiple line cursors for free without a 3rd party package such as multiple-cursors. Not to knock multiple-cursors, as it's very nice and very powerful but I don't use most of its feature set.

As I continue to delve into Emacs, I am finding the default keybindings to be consistent across different modes and packages. C-x C-q to lock read only mode but in Dired it enables editing the buffer. Or using g to refresh the Dired buffer but also ibuffer and tagging files or buffers for deletion are d and x to process is the same in ibuffer and dired. But yeah, more than one way to skin a cat. Maybe I shouldn't mention 'meow'. Pun intended...

matthewstott
Автор

That's a really cool approach. What I do is using a Ranger plugin, which is an actually file manager. Then you type :bulkrename and that's it.

Zeioth
Автор

Maybe someone has already said it, but a lot of graphical file managers actually have bulk file renaming support. I remember Thunar in particular had it, I think I've heard Finder on macOS does as well. Usually you just highlight your files then hit the rename shortcut (often F2) and you get a window popup. There's also ranger's built-in support for vidir with the :bulkrename command which then calls out to your editor for the actual filename editing, and that works really well.
The dired approach is fairly unique in its lack of extra UI or transitions, though. The way you're just already in an editable text thing is pretty interesting.

SoundToxin
Автор

Good to learn this about dired!
I use F2 (rename) in Files on Debian, which works well.

JohnJohnson-dloq
Автор

This is cool !
if I'm stuck on a PC with no GUI for some reason, I might use it. I love that you can see the change before actually write it (aka preview mode on a real bulk renaming software).

ThaitopYT
Автор

Learning Python some time ago I wrote a little CLI script for myself that does just that, basically a search&replace for file and folder names with regex and some options like files or folders only, recursively check subdirectories, enumerate, or fix existing numbers if the order has changed. It's been one of my more useful DIY scripts

namewarvergeben
Автор

I use ranger + vim for this. After exiting vim all the file name edits are applied.

tiberiusvetus
Автор

Actually, you shouldn't need the keybind for wdired-change-to-wdired-mode, as just hitting the i key should do the same. I think in doom emacs they also bound ":w" to wdired-finish-edit, so it basically feels exactly like a normal file buffer.
When I learned of this some months ago, I fell in love with Dired. I need to bulk rename some stuff about once a month, maybe even more often. It's usually just a dozen or so files and quite simple renames, so I never bothered with specialized tools. But since wdired is so intuitive and dired is my default file manager anyway, there is pretty much no need for me to do this manually ever again.
Now if only wdired could replace chmod and chown XD

XanTheXanadul
Автор

yea but I won't ever remember those keybindings.

betterinbooks
Автор

nnn and neovim got me covered for bulk renaming every single time.

marioschroers
Автор

I've written a modular bulk file renaming utility in C# before, and I only ended up using it like twice. The real reason I made it was to probe that I could do it better than my friend. :D

AdroSlice
Автор

Always interesting to see different approaches to get to the same goal. I'm happy with vifm, and it's bulk renaming over vim/neovim 😁 … also worth mentioning: the bulk renaming utility that comes with the Thunar file manager is quite capable and a great alternative for people who prefer a graphical tool.

johannesjung
Автор

I should really finally learn to use dired, as well as eshell....

Anyway, as a long time user of emacs who has used plain emacs until.... well, until perhaps now that I'm experimenting with Doom emacs, it kinda annoys me when you speak of emacs keybindings and mention bindings that aren't default emacs bindings. They are either evil-mode or doom emacs specific - and when I tried customizing doom emacs (I don't want those bindings _nor_ evil mode), simply disabling evil mode seemed to get rid of those weird bindings.

robsku
Автор

Eight Meg And Constantly Swapping — E.M.A.C.S.

Aimsport-video
Автор

Look at him! He started from how to change a wallpaper on a new Linux installation...

janbodnar
Автор

Hey, dt did you know that fff file manager has a bulk rename mode that pipes all your selected files into a vim buffer. After that run the mv command after you have save it.

dungeon
Автор

what's better is you can write an one-time script with Elisp

ctoid
Автор

Simple way to create multiple files in bash: touch foo{1..25}.txt
But I prefer this: touch foo{01..25}.txt

B-geqy