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:


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.

  • $\begingroup$ Works like a charm for me on Linux. $\endgroup$ – Öskå Sep 30 '14 at 13:58
  • $\begingroup$ I suspect this is an OS problem, since Windows, by default, does not utilize a case-sensitive filesystem, although there are some exceptions. $\endgroup$ – bobthechemist Sep 30 '14 at 14:09
  • 3
    $\begingroup$ I am very happy to learn Mathematica as well as English at the same time here.*^_^* $\endgroup$ – partida Sep 30 '14 at 14:23
  • 1
    $\begingroup$ Glad to know there is a workaround, but this ought to be reported to wolfram support. $\endgroup$ – george2079 Sep 30 '14 at 19:37
  • 1
    $\begingroup$ @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. $\endgroup$ – matheorem Oct 22 '17 at 2:39

A simpler alternative:

winRenameFile[f1_, f2_] := Module[{}, RenameFile[f1, "pre" <> f1];
  RenameFile["pre" <> f1, f2]]
  • $\begingroup$ Crap, that is much simpler. $\endgroup$ – kale Sep 30 '14 at 14:15
  • $\begingroup$ Ok! Words like a charm in my computer! Thank you everyone! $\endgroup$ – partida Sep 30 '14 at 14:31
  • $\begingroup$ @user15961 Works* :) $\endgroup$ – Öskå Sep 30 '14 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.