GNOME Bugzilla – Bug 771583
batch rename: Fails to rename on name conflicts in the final name.
Last modified: 2017-10-28 11:17:54 UTC
Batch rename fails to rename the following: How to reproduce (Note: Files are sorted as A-Z): 1. Create some files. touch 0 1 2 2. Select those files -> Right click -> Rename 3. Select the template '[1, 2, 3]' -> Click Rename Result: 2 is renamed as 3. None else is renamed. Expected result: The files should be renamed as per the template. Marking as critical, because C-Z after this causes Nautilus crash, but if this is fixed, hopefully crash won't happen.
please file a new bug for the crash.
Created attachment 335857 [details] [review] Add case for files reordering in batch rename When considering if a file should be moved to the top of the list, it is not enough to look at all files old name and at the new name of the current file, but it is also necessary to compare the old name of the current file with each new name of the other files.
Review of attachment 335857 [details] [review]: Hey Alex, thanks for the patch! In general, the code is repeated and I have the feeling this "ordering files to avoid rename conflicts" could be a standalone function in some utility file, to be used both by the redo/undo operations and batch-rename-dialog. So let's try to do that? If you need some help figuring out a better solution, feel free to ask. But I'm pretty sure we can come with something minimal that goes well with all the cases of reordering. ::: src/nautilus-batch-rename-dialog.c @@ +520,3 @@ + + break; + new_names = g_list_remove_link (new_names, new_names_list); this code kinda does also what the undo/redo functions does. I believe this can be shared up to some point. ::: src/nautilus-file-undo-operations.c @@ +1170,2 @@ { + if (g_strcmp0 (file_name, new_file_name->str) == 0) is not this function an almost copy paste of the one below? if that's the case, you can extract the common bits in a shared function.
Created attachment 337795 [details] [review] batch-rename: fix file reordering before the rename There are cases where the files are not reordered correctly. To fix this, the order of the files is checked until no more changes are made. In this patch, the reordering code is also extracted in a common function.
Created attachment 337796 [details] [review] batch-rename: fix file reordering before the rename There are cases where the files are not reordered correctly. To fix this, the order of the files is checked until no more changes are made. In this patch, the reordering code is also extracted in a common function.
Review of attachment 337796 [details] [review]: This is definitely a step forward, thanks! The code is clean, although still not very clear, but I don't have a better proposal yet :( So this LGTM except for some nitpicks: ::: src/nautilus-batch-rename-utilities.c @@ +145,3 @@ + GList **old_names, + GList **new_files, + GList **old_files, wrong identation, one space more in the ** @@ +164,3 @@ + GFile *old_file; + NautilusFile *file; + GList *files2; since this is the loop's initializer, can you initialize it just before the loop instead? @@ +169,3 @@ + * file1 -> file2 + * file2 -> file3 + GList *old_files_list = NULL; add a new line with */ ::: src/nautilus-batch-rename-utilities.h @@ +67,3 @@ + GList **old_names, + GList **new_files, + GList **old_files, dito
Created attachment 338537 [details] [review] batch-rename: fix file reordering before the rename There are cases where the files are not reordered correctly. To fix this, the order of the files is checked until no more changes are made. In this patch, the reordering code is also extracted in a common function.
Attachment 338537 [details] pushed as fc4135d - batch-rename: fix file reordering before the rename
nobody test patches here? nautilus-3.22.2: ./configure --enable-tracker=no --disable-selinux make ...... In file included from nautilus-file-undo-operations.c:35:0: nautilus-batch-rename-utilities.h:24:28: fatal error: tracker-sparql.h: No such file or directory compilation terminated.
(In reply to ungifted from comment #9) > nobody test patches here? > > nautilus-3.22.2: > ./configure --enable-tracker=no --disable-selinux > make > ...... > > In file included from nautilus-file-undo-operations.c:35:0: > nautilus-batch-rename-utilities.h:24:28: fatal error: tracker-sparql.h: No > such file or directory > compilation terminated. Please refer to bug 775935.
(In reply to ungifted from comment #9) > nobody test patches here? no, thanks for testing :)
*** Bug 775601 has been marked as a duplicate of this bug. ***