From 88d41bb5b57c91b864d6c6d4b2478a2091f6ee5c Mon Sep 17 00:00:00 2001 From: Evgeny Shulgin Date: Wed, 22 Mar 2017 19:45:32 +0300 Subject: batch rename: Do not consider directory "extensions" With a batch renaming using a template, the extension is removed. That is, if we have a file named "some.txt", after renaming using template "[Original file name]YOLO" we will get "someYOLO.txt", and this is correct. But if we renaming folders with a name where there is a dot and subsequent symbols, these characters will be mistakenly considered an extension. For example, after renaming folders "file" -> "fileYOLO", "FILEZ." -> "FILEZ.YOLO" (is correct), but "org.package.library" -> "org.packageYOLO.library", "project-2.0" -> "project-2YOLO.0", "my.files" -> "myYOLO.files", "extra-0.85" -> "extra-0YOLO.85" (is incorrect) To fix this bug we won't search extension if current NautilusFile is a directory. https://bugzilla.gnome.org/show_bug.cgi?id=780326 --- src/nautilus-batch-rename-utilities.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nautilus-batch-rename-utilities.c b/src/nautilus-batch-rename-utilities.c index bb260c545..d7cdbb367 100644 --- a/src/nautilus-batch-rename-utilities.c +++ b/src/nautilus-batch-rename-utilities.c @@ -353,7 +353,10 @@ batch_rename_format (NautilusFile *file, gchar *metadata; file_name = nautilus_file_get_display_name (file); - extension = nautilus_file_get_extension (file); + if (!nautilus_file_is_directory(file)) + { + extension = nautilus_file_get_extension (file); + } new_name = g_string_new (""); @@ -430,11 +433,16 @@ batch_rename_format (NautilusFile *file, { case ORIGINAL_FILE_NAME: { - g_autofree gchar *base_name = NULL; - - base_name = eel_filename_strip_extension (file_name); - - new_name = g_string_append (new_name, base_name); + if (nautilus_file_is_directory(file)) + { + new_name = g_string_append (new_name, file_name); + } + else + { + g_autofree gchar *base_name = NULL; + base_name = eel_filename_strip_extension (file_name); + new_name = g_string_append (new_name, base_name); + } } break; -- cgit v1.2.1