bulletmark / edir

Program to rename, remove, and copy files and directories using your editor
139 stars 8 forks source link

[BUG] Renaming a directory and putting files into the new name #7

Closed NightMachinery closed 3 years ago

NightMachinery commented 3 years ago
./dir1/
./a.txt

to

./dir2/
./dir2/a.txt

will cause dir1 to be renamed to dir1~.

bulletmark commented 3 years ago

It is too difficult to automatically resolve many complicated combinations like this and there is often not a single unique resolution anyhow so you are better off running edir one of more times to rename and/or move files in stages. In short, I am aware of situations like this but I am not planning to add a sophisticated resolver.

schlomo commented 3 years ago

I understand the complexities of solving that, do you see a chance to detection for the problem?

For example I edit a long list and do try to make such a change, then it would be nice to get an error and the chance to try again and go fix my edit.

Another thought: Maybe a "complete" solution is too much, but a simple solution could solve already 95% of such use cases: Simply order the actions like this:

  1. create new and missing directories
  2. rename directories
  3. rename files

Wouldn't that solve this for many common use cases?

bulletmark commented 3 years ago

No, I started somewhat down the track to try to do this when I first created edir but found too many ambiguous situations where it is impossible to work out definitively what the user intends. Simply don't try to do complicated edits in one pass. Do your edits in stages.

NightMachinery commented 3 years ago

@bulletmark I think these set of rules are pretty solid:

Of course, these rules aren't perfect, but they're fairly intuitive and better than the current behavior where weirdly named duplicate directories are created.