Maniphest T71772

File Browser: Rename capitals<->lowercase not supported
Closed, Archived

Assigned To
Germano Cavalcante (mano-wii)
Authored By
Christoph Werner (Taros)
Nov 22 2019, 9:40 AM
Tags
  • BF Blender
  • Blender File
Subscribers
Christoph Werner (Taros)
Germano Cavalcante (mano-wii)
Harley Acheson (harley)
Steff Kempink (mswf)

Description

System Information
version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: 26bd5ebd42e3, type: Release
build date: 2019-11-20, 16:33:00
platform: Windows

Short description of error
Capitals can't be renamed in lowercase and vice versa.

Exact steps for others to reproduce the error

  1. Open file browser.
  2. Rename the first letter of a filename to capital or to lowercase, depending of your file name.

-> Result: Nothing happen.

Example:
When I try to rename "filename.blend" to "Filename.blend", it doesn't work.
I've to rename it to a different letter first, before renaming it to the real name.

Related Objects

Mentioned Here
T63726: User Interface Module
rB26bd5ebd42e3: Update rest of submodules to correct commit for Blender 2.81 release

Event Timeline

Christoph Werner (Taros) renamed this task from File Manager: Rename capitals not supportet to File Manager: Rename capitals not supported.Nov 22 2019, 9:40 AM
Christoph Werner (Taros) renamed this task from File Manager: Rename capitals not supported to File Manager: Rename capitals<->lowercase not supported.
Christoph Werner (Taros) created this task.
Christoph Werner (Taros) added a project: Blender File.
Christoph Werner (Taros) renamed this task from File Manager: Rename capitals<->lowercase not supported to File Browser: Rename capitals<->lowercase not supported.Nov 22 2019, 9:42 AM
Steff Kempink (mswf) added a subscriber: Steff Kempink (mswf).EditedNov 22 2019, 1:05 PM

This is a core issue with Windows. It cannot tell the difference between a path with different capitalization. This is a problem that boggles the mind of everybody who develops with Windows. You can see it if you try to make a "File.txt" and "file.txt" next to each other: Windows will not allow it because it will tell you a file under that same name already exists.

Though you'd think you could automatically apply the workaround you described (rename to something else, then to the final name), this would cause issues for users with .blend files in network drives or folders managed by version control.

Christoph Werner (Taros) added a comment.Nov 22 2019, 3:21 PM

Thank you for the answer.

I've tried it in the regular Windows 10 Explorer and all works fine there. I can rename a lowercase into a capital and vice versa.
The same I've tried with my favorite file manager "Total Commander". There it works, too.

Are you sure there is really still a global windows issue? I'm just asking as a end user.

Steff Kempink (mswf) added a comment.Nov 22 2019, 3:41 PM

The renaming between File and file is working in explorer I see. But an application asking Windows to rename File to file still won't work.
You can see that Windows doesn't see the difference between 'test' and 'Test' in this screenshot, where I already have a file 'test', then when I rename another file to 'Test' (with a capital), Windows throws this up:


The cause is described here too:
https://en.wikipedia.org/wiki/Filename#Letter_case_preservation

Christoph Werner (Taros) added a comment.Nov 22 2019, 5:23 PM
In T71772#815328, @Steff Kempink (mswf) wrote:

The renaming between File and file is working in explorer I see. But an application asking Windows to rename File to file still won't work.
You can see that Windows doesn't see the difference between 'test' and 'Test' in this screenshot, where I already have a file 'test', then when I rename another file to 'Test' (with a capital), Windows throws this up:


The cause is described here too:
https://en.wikipedia.org/wiki/Filename#Letter_case_preservation

Yes, your example is logical if you already have a file, that has the same name.
But is it the same what I say above? Do I misunderstand something?

Steff Kempink (mswf) added a comment.EditedNov 25 2019, 3:05 PM

Yes, renaming does work correctly from Windows Explorer directly; probably they do work around the issue with the filesystem directly which is easier as an OS. Renaming 2 files to "test" and "Test" is an example I gave as a way to expose the underlying issue.

Christoph Werner (Taros) added a comment.Nov 25 2019, 3:20 PM

OK. Nevertheless this should be fixed.
For the user it is not really understandable, why Blender can't rename a single Letter in a filename, but all other apps can do it.

Best wishes
Chris

Germano Cavalcante (mano-wii) lowered the priority of this task from 90 to 30.Nov 27 2019, 4:08 PM
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).

How do you rename a file by the blender file browser?

Harley Acheson (harley) added a subscriber: Harley Acheson (harley).Nov 27 2019, 5:26 PM

How do you rename a file by the blender file browser?

You can right-click on any file name and select "Rename" from the context menu.

In a nutshell we are specifically not allowing a rename that involves nothing but a change of case on Windows. It is indirectly because on Windows our file systems are case-preserving but case-insensitive. So we can save file names that have mixed case like "Mixed.text", but cannot have two files in the same location with same name like "Mixed.txt" and "mixed.txt" together.

So when attempting a rename that involves only a case change we are first checking if the new and old names are equal. In this case that is not true so we continue. But then we check if a file of the new name already exists. In this case it is true so we don't allow the rename to continue. blender\editors\space_file\file_draw.c, renamebutton_cb()

If we did not do this test for file existance (BLI_exists) then the requested case-change rename would work. However, it would screw up in the situation where the new file name really does already exist. So in the case of renaming "one.txt" to "two.txt" when we already have a "two.txt". In that case our BLI_rename() will happily do so, deleting "two.txt" and renaming "one.txt" to "two.txt".

It would be hard to deal with these two situation separately because in both cases the new name is an existing file. It would add complication and probably have corner cases that are hard to anticipate. We could check to see if new file exists but is the same as old file case-insensitively, but that would screw up if a user is actually using a file system that is case-sensitive.

I'd say the best thing is just treat this as a quirk of your operating system and do it in two steps. If you want to change just the case of file? Change it to some other name first then change back while also changing case. So "mixed.txt" -> "_mixed.txt -> "Mixed.txt". Or rename it outside of the File Browser.

Germano Cavalcante (mano-wii) changed the task status from Unknown Status to Unknown Status.Nov 27 2019, 6:47 PM
Germano Cavalcante (mano-wii) claimed this task.
In T71772#819627, @Harley Acheson (harley) wrote:

You can right-click on any file name and select "Rename" from the context menu.

In my case, since I use Right Click Select, the button is W.
It is strange but follows the convention of the context menu.

It might be a good idea to keep both keys in this case.

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 3a7a142e310..185fc1892fb 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -1809,7 +1809,8 @@ def km_file_browser(params):
          {"properties": [("increment", -10)]}),
         ("file.filenum", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "ctrl": True},
          {"properties": [("increment", -100)]}),
-        op_menu("FILEBROWSER_MT_context_menu", params.context_menu_event),
+        op_menu("FILEBROWSER_MT_context_menu", {"type": 'W', "value": 'PRESS'}),
+        op_menu("FILEBROWSER_MT_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
     ])
 
     return keymap

But that's another issue.

@Harley Acheson (harley), what do you think is best:

  • close this report since it's a limitation due to the way windows system checks for existing files;
  • confirm as low priority;
  • ToDo (T63726)
Germano Cavalcante (mano-wii) changed the task status from Unknown Status to Unknown Status.Nov 27 2019, 6:50 PM
Harley Acheson (harley) added a comment.Nov 27 2019, 7:08 PM

I honestly don't think it can be a "to do".

And although it seems odd, I don't really even consider it a limitation for Windows. The test for "Does this file exist?" definitely returns what it is expected for any system that is case-insensitive. I honestly don't know how we could deal with this special case in a way that would not screw up if you connected to a Linux share through Samba where there were existing files that then appeared duplicated. In that case BLI_rename() would delete the file of the new name before renaming.

This workaround, having to rename twice when just changing case, was something we dealt with in the Windows File Manager for years - since 1995 - and was only just changed (finally) recently with Windows 10.

Germano Cavalcante (mano-wii) changed the task status from Unknown Status to Unknown Status.Nov 27 2019, 7:26 PM

Closing then.
It's not worth creating an internal workaround that messes up the code to solve this.

Christoph Werner (Taros) added a comment.EditedNov 28 2019, 8:22 AM

Small update what windows does, if you rename a file from "myimage.png" to "Myimage.png" in a different folder.
If you copy the renamed version then to a folder where a version exists that is named in the orgin spelling "myimage.png", the following happens:
Windows realise there is already a filename with same name, and ask to overwrite it.

So Windows is basically doing, what every system does, but in the case of renaming it allows the user to rename a single Letter of a filename inside a folder.

Just for info.