Giter Club home page Giter Club logo

bulka's Introduction

bulka

...is yet another bulk rename tool that lets you rename selected files in your $EDITOR / vi.

Installation

Requires python 3.6+

Just grab bulka script and put somewhere in your $PATH, don't forget to chmod +x it.

Usage

bulka -h:

  1. run bulka file1 file2 file3 ... or e.g. find ... | bulka

  2. your $EDITOR will open: edit names, save & close editor

then, if all checks* are passed, it will rename your files:

  1. to temporary names, to avoid conflicts like A -> B and B -> A at the same time
  2. from temporary to desired new names (creating missing folders if needed)

(*) Checks that:

  1. there are no duplicates
  2. nothing will get overwritten
  3. no lines are missing
  4. names actually changed

Limitations:

  • doesn't check permissions beforehand

Motivation

lf

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:

  1. I like vim
  2. I really don't like emacs style editing
  3. 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.

So what about alternatives?

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)
  • 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:

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

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.

bulka's People

Contributors

mahoushoujomivutilde avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.