[nautilus/wip/csoriano/nautilus-3.24.1: 2/14] batch rename: Do not consider directory "extensions"



commit 314ad2c43135960b84d022abf87aa5df76075544
Author: Evgeny Shulgin <izarizar mail ru>
Date:   Wed Mar 22 19:45:32 2017 +0300

    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 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-batch-rename-utilities.c b/src/nautilus-batch-rename-utilities.c
index bb260c5..d7cdbb3 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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]