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

File order matters. Files can be overwritten unexpectedly. #39

Open
jaekyeom opened this issue Aug 9, 2021 · 4 comments
Open

File order matters. Files can be overwritten unexpectedly. #39

jaekyeom opened this issue Aug 9, 2021 · 4 comments

Comments

@jaekyeom
Copy link

jaekyeom commented Aug 9, 2021

Steps to reproduce:

  1. Run for i in $(seq 0 9); do touch "file ($i).txt"; done
  2. Run vimv *
  3. Rename the 10 files from
    file (0).txt
    file (1).txt
    file (2).txt
    file (3).txt
    file (4).txt
    file (5).txt
    file (6).txt
    file (7).txt
    file (8).txt
    file (9).txt
    
    to
    file (1).txt
    file (2).txt
    file (3).txt
    file (4).txt
    file (5).txt
    file (6).txt
    file (7).txt
    file (8).txt
    file (9).txt
    file (10).txt
    
  4. All that's left is file (10).txt 😢
@jaekyeom jaekyeom changed the title File order matters. Files can be overwritten accidentally. File order matters. Files can be overwritten unexpectedly. Aug 9, 2021
@Tr4il
Copy link

Tr4il commented Aug 8, 2022

I just royally messed up, running into this issue. My fault for using this on "production" data, but watch out when using this little tool for changing a sequence a step up or down.

@theoratkin
Copy link
Contributor

I destroyed multiple (thankfully not important) files because of this. For now I switched to vidir from moreutils, it doesn't suffer from this problem and also allows reordering and deleting files.

@opello
Copy link

opello commented Nov 15, 2022

I ran into this and was also annoyed, kind of brute force fixed it, probably not a great implementation:

opello@4a94aba

@musjj
Copy link

musjj commented Aug 31, 2023

I think vimv can learn from nnn's design. In nnn there's a batch rename mode similar to vimv, but the difference is that each file to be renamed is prefixed by a numeric label. For example:

1 file.txt
2 image.jpg
3 doc.pdf

This way, you can rename/reorder/etc. fearlessly, knowing that each file will be associated correctly. Each labelled line will always be statically associated with the original file path, so there's zero need for the program to make guesses.

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

5 participants