# What's wrong with this RenameFile?

Bug introduced in 5.2 or earlier and persisting through 11.2.0
The bug appears on Windows only

I want to rename a .txt file.

For example create a file on your Desktop and name it use TEST.TXT, now I want to rename it to test.txt:

RenameFile["C:\\Users\\Administrator\\Desktop\\TEST.TXT",


It seems that RenameFile does not distinguish the UPPER CASE from the lower case in the file extensions. So how can I rename this file?

Ps: I use MATLAB in my homework, but MATLAB can only read *.m in terms of *.M files. So I must rename the *.M files. Therefore I use *.TXT and *.txt to make a example.

• Works like a charm for me on Linux. – Öskå Sep 30 '14 at 13:58
• I suspect this is an OS problem, since Windows, by default, does not utilize a case-sensitive filesystem, although there are some exceptions. – bobthechemist Sep 30 '14 at 14:09
• I am very happy to learn Mathematica as well as English at the same time here.*^_^* – partida Sep 30 '14 at 14:23
• Glad to know there is a workaround, but this ought to be reported to wolfram support. – george2079 Sep 30 '14 at 19:37
• @bobthechemist I don't think this is the problem of windows. windows cmd has ren function which has no problem rename upper case to lower case. I think this is apparently a bug. Latest 11.2 still has this problem. – matheorem Oct 22 '17 at 2:39

winRenameFile[f1_, f2_] := Module[{}, RenameFile[f1, "pre" <> f1];