After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 770870 - Batch renaming: Can't search and replace with "." or ".."
Batch renaming: Can't search and replace with "." or ".."
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: File and Folder Operations
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-09-05 07:43 UTC by Sebastian Keller
Modified: 2016-09-06 09:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
batch-rename-dialog: fix search & replace for . and .. (3.29 KB, patch)
2016-09-05 09:39 UTC, Alexandru Pandelea
none Details | Review
batch-rename-dialog: fix search & replace for . and .. (3.33 KB, patch)
2016-09-05 18:30 UTC, Alexandru Pandelea
committed Details | Review

Description Sebastian Keller 2016-09-05 07:43:42 UTC
When using batch renaming with the search and replace feature, it is not possible to replace a string with "." or ".." as nautilus claims those are invalid file names. While it is true that these by themselves would be invalid file names, the file names resulting from the replacement are still valid in most cases. It seems like the check for valid file names is run on the replacement string rather than on the resulting file names.
Comment 1 Alexandru Pandelea 2016-09-05 09:39:27 UTC
Created attachment 334776 [details] [review]
batch-rename-dialog: fix search & replace for . and ..

In the replace mode, when "." or ".." were typed in the replace entry,
there would always pop up an error, saying that a file would have an
invalid name.

In this case, instead of checking the entry, the check must actually be
done to all the new names to see if any of those are equal to "." or
"..".

Since the new names are now used in this function, these have to be
obtained before.
Comment 2 Carlos Soriano 2016-09-05 14:23:41 UTC
Review of attachment 334776 [details] [review]:

Hey, thanks for the patch! Some nitpicks

::: src/nautilus-batch-rename-dialog.c
@@ +1995,3 @@
+            if (g_strcmp0 (new_name->str, ".") == 0)
+            {
+                have_unallowed_character_dot = TRUE;

you can break; here

@@ +2012,3 @@
+            if (g_strcmp0 (new_name->str, "..") == 0)
+            {
+        {

you can break; here
Comment 3 Alexandru Pandelea 2016-09-05 18:30:44 UTC
Created attachment 334845 [details] [review]
batch-rename-dialog: fix search & replace for . and ..

In the replace mode, when "." or ".." were typed in the replace entry,
there would always pop up an error, saying that a file would have an
invalid name.

In this case, instead of checking the entry, the check must actually be
done to all the new names to see if any of those are equal to "." or
"..".

Since the new names are now used in this function, these have to be
obtained before.
Comment 4 Carlos Soriano 2016-09-06 07:56:28 UTC
Review of attachment 334845 [details] [review]:

LGTM thanks!!
Comment 5 Alexandru Pandelea 2016-09-06 09:32:32 UTC
Attachment 334845 [details] pushed as c7fb994 - batch-rename-dialog: fix search & replace for . and ..