Page MenuHome

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

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.

Details

Type
Bug

Event Timeline

Christoph Werner (Taros) renamed this task from File Manager: Rename capitals not supportet to File Manager: Rename capitals not supported.Fri, Nov 22, 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) renamed this task from File Manager: Rename capitals<->lowercase not supported to File Browser: Rename capitals<->lowercase not supported.Fri, Nov 22, 9:42 AM

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.

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.

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

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.EditedMon, Nov 25, 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.

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 Needs Triage by Developer to Needs Information from User.Wed, Nov 27, 4:08 PM

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

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.

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)

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.

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

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.