Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bulk rename #264

Open
aminnairi opened this issue Jan 2, 2024 · 1 comment
Open

Support for bulk rename #264

aminnairi opened this issue Jan 2, 2024 · 1 comment

Comments

@aminnairi
Copy link

aminnairi commented Jan 2, 2024

It would be awesome to support bulk renaming files in the context of renaming a huge set of file without having to rename those one-by-one.

For now, if we need to rename, let's say 10 files, we need to hit the keybind 10 times. It can be quite cumbersome for a lot of file rename.

Also, it would be great to use our favorite text editor (like Neovim for instance) in order to have a preview of all the files to rename (that have been marked for bulk rename) and make changes quickly. This can leverage Neovim & Vim's macro feature to speed up the process for complex file rename as well as for quick file rename. Emacs can also benefit from this since it implements macros as well.

Any editor would do just fine and it would be great to be able to setup the bulk rename program for that.

# ~/.config/felix/config.yml
rename:
  bulk:
    program: nvim #default to the "default" key if specified, or $EDITOR otherwise

The bulk renaming can be done using a temporary file, and then converting every old marked files to the new ones (this could use a vector for the old files and a vector for the new files). If the new vector does not contain the same amount of elements (i.e lines), the operation should be aborted in order to keep consistency within the filesystem.

As for the documentation and the default keybinds, there is room for that in visual mode.

V (uppercase)      :Switch to the linewise visual mode.
  - y              ...
  - d              ...
  - c              :In the visual mode, bulk rename selected item(s) inside your default editor. 
  - "ay            ...
  - "ad            ...
  - "Ay            ...
  - "Ad            ...

One thing to consider is the undo for this operation. I suggest keeping track of the files that have been renamed in a hash map and allowing the user to revert the bulk renaming by re-applying the changes to those files in the said hash map.

Do you think that this could be done for Felix?

Thank you for your hard work on Felix!

@aminnairi aminnairi mentioned this issue Jan 2, 2024
@RioNight
Copy link

RioNight commented Jan 5, 2024

This would make more sense and be more powerful if we have a select file option. So, we could select multiple files that we want to rename (say with ), and then press c to rename the files with a temp file.

Pressing c would open the temp file with a list of the filenames in vim like:

file2
file4
file7

To rename, you would simply change each filename to its new filename:

file2_new
file4_new
file7_new

I believe there is a select file feature issue opened here: #263.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants