Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Renaming a directory to all uppercase on Windows?

1,282 views
Skip to first unread message

walto...@gmail.com

unread,
Dec 10, 2008, 7:49:39 PM12/10/08
to
This seems impossible with the [file rename] command.

file rename -force folder FOLDER
error renaming "folder" to "FOLDER/folder": trying to rename a volume
or move a directory into itself

This is because on Windows, file names are not case sensitive. And so
since FOLDER is seen as an existing directory, the [file rename]
command takes the second form:

file rename ?-force? ?- -? source ?source ...? targetDir

And so it tries to move the directory into itself. The only
workaround I can think of is:
file rename -force folder this_is_a_hack
file rename -force this_is_a_hack FOLDER

But, of course, this is a hack. And it takes twice as long. Am I
missing something?

burgerbisquit

unread,
Dec 11, 2008, 1:35:13 AM12/11/08
to
You could use something like this:
exec cmd /K rename test TEST
Windows, of course.

walto...@gmail.com

unread,
Dec 11, 2008, 1:47:29 AM12/11/08
to

I'm sure that would be even slower. If I'm renaming 10,000 files, I
would be exec'ing 10,000 instances of cmd. I think it's silly that
you can't change the capitalization of a file name with one simple use
of [file rename]

Donal K. Fellows

unread,
Dec 11, 2008, 5:33:04 AM12/11/08
to
walton.p wrote:
> But, of course, this is a hack.  And it takes twice as long.  Am I
> missing something?

No. It's how life is on Windows. (You have the same restriction in
Explorer too.)

Donal.

APN

unread,
Dec 11, 2008, 5:48:49 AM12/11/08
to
On Dec 11, 3:33 pm, "Donal K. Fellows" <donal.k.fell...@man.ac.uk>
wrote:

Nope, Explorer will allow you to change the case of a file/dir name,
at least on XP.

The basic issue is that the file rename command sees FOLDER exists
(actual name folder) and as per its documented behaviour assumes you
are trying to move the source file into that directory. Given the
source is folder itself, it complains about moving a directory onto
itself.

IMHO, the semantics of "file rename", which probably came from the
unix mv command, are broken. But it is behaving as documented.

/Ashok

walto...@gmail.com

unread,
Dec 11, 2008, 2:21:14 PM12/11/08
to

Yep, that's exactly it. Thank you for that explanation, Ashok.

It's obvious that this "file rename" behavior was intended for a case-
sensitive filesystem. The fix should be simple... ie., If string eq -
nocase $source $target, then use the first documented "file rename"
behavior when on a case-insensitive OS.

Donald Arseneau

unread,
Dec 11, 2008, 6:41:19 PM12/11/08
to
On Dec 10, 4:49 pm, walton.p...@gmail.com wrote:
> file rename -force folder FOLDER
> error renaming "folder" to "FOLDER/folder": trying to rename a volume
> or move a directory into itself

Yes... the inconsistent treatment of setting a file name
versus looking up a file name on windows. (Setting is
case-sensitive, but looking up is insensitive.)

It looks like you will have to go through an intermediate step

if { [string equal -nocase $f1 $f2] } {
set f3 [file join [file dirname $f1] [my-temp-[file tail $f1]]
file rename $f1 $f3
set f1 $f3
}
file rename $f1 $f2

Óscar Fuentes

unread,
Dec 11, 2008, 7:00:16 PM12/11/08
to
Donald Arseneau <as...@triumf.ca> writes:

> On Dec 10, 4:49 pm, walton.p...@gmail.com wrote:
>> file rename -force folder FOLDER
>> error renaming "folder" to "FOLDER/folder": trying to rename a volume
>> or move a directory into itself
>
> Yes... the inconsistent treatment of setting a file name
> versus looking up a file name on windows. (Setting is
> case-sensitive, but looking up is insensitive.)

This is inconsistent only if you think as a computer user with a unix
background. Anyone will say that Donald Arseneau names the same person
as DONALD ARSENEAU, but at the same time have personal preferences about
how to capitalize words.

Face it, case-sensitive filesystems looks bizarre to anyone except those
programmers versed on case-sensitive programming languages, which are
less than 1% of the world population.

[snip]

--
Oscar

Donald Arseneau

unread,
Dec 14, 2008, 5:28:03 AM12/14/08
to
On Dec 11, 4:00 pm, Óscar Fuentes <o...@wanadoo.es> wrote:

> Donald Arseneau <a...@triumf.ca> writes:
> > Yes... the inconsistent treatment of setting a file name
> > versus looking up a file name on windows. (Setting is
> > case-sensitive, but looking up is insensitive.)
>
> This is inconsistent only if you think as a computer user with a unix
> background.

Not true! I have more af a VMS background, which uses case-
insensitive filenames, but it is consistently case-insensitive.

Read again what I wrote. How can such a dichotomy equal consistency.

Donald Arseneau as...@triumf.ca

Óscar Fuentes

unread,
Dec 14, 2008, 6:15:44 AM12/14/08
to
Donald Arseneau <as...@triumf.ca> writes:

> On Dec 11, 4:00 pm, Óscar Fuentes <o...@wanadoo.es> wrote:
>> Donald Arseneau <a...@triumf.ca> writes:
>> > Yes... the inconsistent treatment of setting a file name
>> > versus looking up a file name on windows. (Setting is
>> > case-sensitive, but looking up is insensitive.)
>>
>> This is inconsistent only if you think as a computer user with a unix
>> background.
>
> Not true! I have more af a VMS background, which uses case-
> insensitive filenames, but it is consistently case-insensitive.

Nowadays computers try to be natural to use to non-IT people.

> Read again what I wrote. How can such a dichotomy equal consistency.

I explained it on the part of the message you snipped.

--
Oscar

Uwe Klein

unread,
Dec 14, 2008, 6:21:10 AM12/14/08
to

Millions of Lemmings can't be wrong ;-)


a question:
if I have two files named

Abcdef.txt and abcdeF.txt

which one will windows show me
when i ask for any other case permutation ?

( IMHO namemangling could be tolerated in a shell
if I can switch it off but not in a filesystem )

uwe

Óscar Fuentes

unread,
Dec 14, 2008, 6:45:00 AM12/14/08
to
Uwe Klein <uwe_klein_...@t-online.de> writes:

> Óscar Fuentes wrote:
>> Donald Arseneau <as...@triumf.ca> writes:
>>
>>
>>>On Dec 10, 4:49 pm, walton.p...@gmail.com wrote:
>>>
>>>>file rename -force folder FOLDER
>>>>error renaming "folder" to "FOLDER/folder": trying to rename a volume
>>>>or move a directory into itself
>>>
>>>Yes... the inconsistent treatment of setting a file name
>>>versus looking up a file name on windows. (Setting is
>>>case-sensitive, but looking up is insensitive.)
>>
>>
>> This is inconsistent only if you think as a computer user with a unix
>> background. Anyone will say that Donald Arseneau names the same person
>> as DONALD ARSENEAU, but at the same time have personal preferences about
>> how to capitalize words.
>>
>> Face it, case-sensitive filesystems looks bizarre to anyone except those
>> programmers versed on case-sensitive programming languages, which are
>> less than 1% of the world population.
>
> Millions of Lemmings can't be wrong ;-)

Case-insensitive, case-preserving text is a common practice since
centuries ago. Do you think that the world should change to adapt to the
weirdness of computer geeks?

> a question:
> if I have two files named
>
> Abcdef.txt and abcdeF.txt
>
> which one will windows show me
> when i ask for any other case permutation ?

You can't have two files that differs only on capitalization on a FAT32
or NTFS file system. Those files would be the same.

> ( IMHO namemangling could be tolerated in a shell
> if I can switch it off but not in a filesystem )

Uh?

--
Oscar

Arnold Snarb

unread,
Dec 14, 2008, 6:11:03 PM12/14/08
to
=?windows-1252?Q?=D3scar_Fuentes?= wrote:

> Case-insensitive, case-preserving text is a common practice since
> centuries ago. Do you think that the world should change to adapt to the
> weirdness of computer geeks?

Yes! But why stop there? Normal people have been using
plain old natural languages like English and Chinese
to communicate with one another for thousands of years.
They ought to be able to control their computers the same way!
It's utterly unreasonable to make normal people have to think
like those geeky weird freakishly unnatural computer programmers
just to use a PC.

Who do those "computer programmers" think they are, anyway?
What makes them so special that they're the only ones allowed
to use computers? We should make the machines think like we do,
not the other way around.

Yeesh.


--Arnold


[*] Footnote for the sarcasm-impaired: the above is an example
of "Reductio ad absurdum". You can look it up on Wikipedia.

walto...@gmail.com

unread,
Dec 14, 2008, 7:28:07 PM12/14/08
to

The point is that on Windows, which is the most popular desktop
operating system, file names are case insensitive and obviously users
like to change the case of file names for aesthetic reasons. Whether
or not this is stupid behavior of Windows or whether or not non-geeks
should be changing file names, this is how it is.

Users want software to WORK and be easy to use. The bottom line is
Tcl is cross-platform and designed to be used on Windows, and the file
renaming behavior of Tcl is broken on Windows. Yes, there is a way
around it by using an intermediate temporary file, but this is slower
and should be unnecessary.

The problem isn't about coming up with a patch, because this should be
a retardedly easy thing to fix. The problem is in the design of the
"file rename" command, which should allow "folder" to be renamed to
"Folder" instead of trying to move the directory into itself.

Bruce Hartweg

unread,
Dec 15, 2008, 10:23:45 AM12/15/08
to

well, to some it is NOT broken. you speak of the end user shouldn;t
have to think like a computer geek. This is true - but a programmer
*should*.

Bruce

Óscar Fuentes

unread,
Dec 15, 2008, 10:36:52 AM12/15/08
to
Bruce Hartweg <Bruce-D...@example.com> writes:

>> The problem isn't about coming up with a patch, because this should be
>> a retardedly easy thing to fix. The problem is in the design of the
>> "file rename" command, which should allow "folder" to be renamed to
>> "Folder" instead of trying to move the directory into itself.
>
> well, to some it is NOT broken. you speak of the end user shouldn;t
> have to think like a computer geek. This is true - but a programmer
> *should*.

How is it not broken? Tcl's [file rename] doesn't support an operation
that is pretty natural on one platform (Windows). Instead of
acknowledging a bug or limitation on [file rename] some people here are
exposing their religious prejudices against a platform supported by Tcl.

--
Oscar

Bruce Hartweg

unread,
Dec 15, 2008, 12:20:52 PM12/15/08
to

so instead of starting a religious discussion on how windows is "right"
since that's what people have done for centuries, just submit a bug
(and more helpful, a patch) and move on.

Bruce

Óscar Fuentes

unread,
Dec 15, 2008, 12:45:53 PM12/15/08
to
Bruce Hartweg <Bruce-D...@example.com> writes:

> Óscar Fuentes wrote:
>> Bruce Hartweg <Bruce-D...@example.com> writes:
>>
>>>> The problem isn't about coming up with a patch, because this should be
>>>> a retardedly easy thing to fix. The problem is in the design of the
>>>> "file rename" command, which should allow "folder" to be renamed to
>>>> "Folder" instead of trying to move the directory into itself.
>>> well, to some it is NOT broken. you speak of the end user shouldn;t
>>> have to think like a computer geek. This is true - but a programmer
>>> *should*.
>>
>> How is it not broken? Tcl's [file rename] doesn't support an operation
>> that is pretty natural on one platform (Windows). Instead of
>> acknowledging a bug or limitation on [file rename] some people here are
>> exposing their religious prejudices against a platform supported by Tcl.
>>
>
> so instead of starting a religious discussion on how windows is
> "right"

The only religious stance here was, precisely, that Windows is wrong. No
one explained why case-insensitive, case-preserving file names are
silly, apart from "my platform of choice doesn't do that, so it is
wrong". I'll really like to hear a counter-argument for what I explained
on my first message. That's what people refer to as a constructive
discussion.

> since that's what people have done for centuries,

yeah, people is so stupid. See what have they done after all those
centuries. OTOH, those unix hackers are smart: they discovered what's
natural to use for an human being in just a few years. An *intelligent*
human being, that is. The stupid people use Windows.

No, I'm not being constructive here <g>

> just submit a bug
> (and more helpful, a patch) and move on.

Next time please start with this proposal, instead of casting doubts on
the intelligence of the designers and users of some other platform.

--
Oscar

Bryan Oakley

unread,
Dec 15, 2008, 1:03:00 PM12/15/08
to
On Dec 15, 11:20 am, Bruce Hartweg <Bruce-DoNot...@example.com> wrote:
> Óscar Fuentes wrote:

This doesn't sound like a religious discussion to me. I think Óscar
got it right -- from a human perspective [file rename] does the wrong
thing in this specific case (no pun intended). I think that's true
whether you look at it through end-user eyes or geeky eyes.

It's amazing that it's taken so long for someone to notice this.
Though, come to think of it I think I stumbled on it a year or two ago
and simply used an intermediate name to accomplish the task. Given how
many times Tcl has made my life easier over the years, I think it can
be forgiven for making it harder once in a while for those pesky edge
cases.

Gilles

unread,
Dec 15, 2008, 3:27:03 PM12/15/08
to
In article <m3r649w...@telefonica.net>,

Óscar Fuentes <o...@wanadoo.es> wrote:
> The only religious stance here was, precisely, that Windows is wrong. No
> one explained why case-insensitive, case-preserving file names are
> silly,

They are not silly but for certain characters (like uppercase barred D*)
which can have or ∂ as lowercase or a barred d depending on languages,
how do you do? Or, in Turkish, where the capital I has a lowercase i
without a dot (ı)? Is uppercase CONFIG.SYS corresponding to lowercase
confıg.sys in Turkish only? Should straße.doc be STRAßE.DOC or
STRASSE.DOC? Or should a file name carry with itself a language
metadata? Why not? But not in today, widely available filesystems. I
know these are certainly rare cases but they exists. And it doesn't
prevent Mac HFS or Windows NTFS to exist (and to work quite well for the
user). Anyway, true 'case-insensitiveness' is not possible since a
one-to-one mapping for certain characters is not possible.

Gilles.

* I know there two different codes in Unicode for the two
(similar-looking) uppercase barred D.

See
http://74.125.77.132/search?q=cache:Jvb6fmk_20kJ:hypermail.org/usefor/200
2/Aug/0204.html for some examples in handling case-insensitiveness (in a
different context).

Óscar Fuentes

unread,
Dec 15, 2008, 4:09:59 PM12/15/08
to
Gilles <ty...@free.fr> writes:

>> The only religious stance here was, precisely, that Windows is wrong. No
>> one explained why case-insensitive, case-preserving file names are
>> silly,
>
> They are not silly but for certain characters (like uppercase barred

> D*) which can have or ∂ as lowercase or a barred d depending on


> languages, how do you do? Or, in Turkish, where the capital I has a

> lowercase i without a dot (ı)? Is uppercase CONFIG.SYS corresponding
> to lowercase confıg.sys in Turkish only?

If this is the assumption of the non computer-savvy Turkish user, yes,
it should the same.

> Should straße.doc be STRAßE.DOC or STRASSE.DOC?

To both, if the rules applied to regular writing says so.

> Or should a file name carry with itself a language
> metadata? Why not? But not in today, widely available filesystems. I
> know these are certainly rare cases but they exists. And it doesn't
> prevent Mac HFS or Windows NTFS to exist (and to work quite well for the
> user). Anyway, true 'case-insensitiveness' is not possible since a
> one-to-one mapping for certain characters is not possible.

You are pointing out limitations on the case-insensitiveness, mostly
coming from the USA-centric roots of character encodings and file
systems. IMHO, those limitations are not enough to invalidate the
convenience of the case-insensitive option, Which would be the same as
throwing the baby out with the bath water. Going the case-sensitive way
seems to me as user-unfriendly. Apart from programmers who like to work
on case-sensitive programming languages, I found nobody who thinks that
it's "natural" that MyPhotos is a different folder than Myphotos.

--
Oscar

Michael Fremlins

unread,
Dec 15, 2008, 7:21:53 PM12/15/08
to
walto...@gmail.com wrote:

> The point is that on Windows, which is the most popular desktop
> operating system, file names are case insensitive

Not quite the whole truth.

From:
http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx


"FILE_FLAG_POSIX_SEMANTICS
0x0100000

Access will occur according to POSIX rules. This includes allowing
multiple files with names, differing only in case, for file systems that
support that naming. Use care when using this option, because files
created with this flag may not be accessible by applications that are
written for MS-DOS or 16-bit Windows."

Donal K. Fellows

unread,
Dec 16, 2008, 9:41:07 AM12/16/08
to
Óscar Fuentes wrote:
> You are pointing out limitations on the case-insensitiveness, mostly
> coming from the USA-centric roots of character encodings and file
> systems. IMHO, those limitations are not enough to invalidate the
> convenience of the case-insensitive option, Which would be the same as
> throwing the baby out with the bath water. Going the case-sensitive way
> seems to me as user-unfriendly. Apart from programmers who like to work
> on case-sensitive programming languages, I found nobody who thinks that
> it's "natural" that MyPhotos is a different folder than Myphotos.

The problem with case-insensitivity is that how you actually achieve
it varies by language. Turkish is the canonical nasty example, but not
the only one (the rules for dealing with accents really do vary). By
contrast, a fully case-sensitive system can just pass the filename
bytes around and doesn't have to know what they mean at all.

And yes, it's fairly common for systems to have a multitude of human
languages in use on a single system, especially in places like
universities that take foreign students...

Donal (this is just an inherently nasty problem).

Uwe Klein

unread,
Dec 19, 2008, 4:35:23 AM12/19/08
to
Óscar Fuentes wrote:

> seems to me as user-unfriendly. Apart from programmers who like to work
> on case-sensitive programming languages, I found nobody who thinks that
> it's "natural" that MyPhotos is a different folder than Myphotos.
>

A filesystem is a filesystem and not a case mangler.

If you really want that feature you can put it in the user shell
together with 8.3 mapping.

uwe

0 new messages