...is yet another bulk rename tool that lets you rename selected files in your $EDITOR
/ vi.
Requires python 3.6+
Just grab bulka
script and put somewhere in your $PATH
, don't forget to chmod +x
it.
bulka -h
:
-
run
bulka file1 file2 file3 ...
or e.g.find ... | bulka
-
your
$EDITOR
will open: edit names, save & close editor
then, if all checks* are passed, it will rename your files:
- to temporary names, to avoid conflicts like A -> B and B -> A at the same time
- from temporary to desired new names (creating missing folders if needed)
- there are no duplicates
- nothing will get overwritten
- no lines are missing
- names actually changed
- doesn't check permissions beforehand
I use it as replacement for native rename
command in lf file manager.
cmd bulk ${{
bulka $(basename -a -- $fx)
lf -remote 'send load'
lf -remote 'send unselect'
}}
map r bulk
Why? Because:
- I like vim
- I really don't like emacs style editing
- I believe that
rename
and bulk rename shouldn't be 2 different commands that use different editing hotkeys
But of course, bulka
is perfectly usable on its own.
Why write your own? Sadly, none of them were satisfying to me.
-
vidir is good, but:
- prefixes each line with a number which makes macros and
:norm
/g
commands harder to apply - by design can and will delete your files, if you accidentally deleted some lines (no, you can't turn it off)
- prefixes each line with a number which makes macros and
-
mmv is even better:
- no prefixes
- aborts if lines are missing
- but it can overwrite files not included in rename without any warning, which is not a bug.
-
vimv:
- smallest of them all
- written in bash
- no prefixes
- aborts if lines are missing
- can use
git mv
- but sometimes your files will get silently overwritten because:
- it doesn't handle cyclic renames (A -> B and B -> A)
- it doesn't check for duplicates
So yes, most of the cases here were me going "wtf, where did that file go?".
Note, that GNU's mv
by default will also overwrite files, the problem with the
above is that unlike with mv
, you can't force it to check before overwriting.
But there is another tool:
- dmulholl/vimv - same name, but has nothing to do with the above:
- probably the most feature rich and better designed of them all:
- can delete files, but you have to explicitly enable it
- can overwrite files, but you have to explicitly enable it
- can use
git mv
, but you have to explicitly enable it - supports cyclic renames
- written in rust
- if I’d known about it, I probably wouldn't bother with
bulka
- probably the most feature rich and better designed of them all:
This is really good tool, and I suggest you to give it a try. bulka
's only
advantage compared to it is the fact that it is written in ubiquitous scripting
language, and you don't have to compile it (which is good for e.g. portable
configuration that you use across multiple architectures), and performance
wise - doesn't matter since renaming is just i/o bound anyway.