Skip to content

batch-rename: fix batch renaming logic for colliding filenames

Fatih Akca requested to merge akca/nautilus:batch-rename-fix into master

There are some cases which cause infinite loop in the batch_rename_sort_lists_for_rename(), following the crash of Nautilus or the whole system freeze due to huge mem-leak.

Sorting the file list is not enough to fix batch-renaming in some cases. If some of the old filenames are also included in the new filenames, we need to be sure that common names are handled correctly. E.g. if we have files named as 0 and 1, we can't rename them to 1 and 0 directly, we need to use a temporary filename for one of the files.

So, batch_rename_sort_lists_for_rename() is deprecated and a new solution implemented which detects collision cycles and fixes them first.

Then, fixes the rest with renaming colliding files to temporary names (original filename + ".tmp_batch_rename_" + random string of 5 characters). Later, renames them back to intended names.

Fixes #150 (closed).

Edited by Fatih Akca

Merge request reports