0

I have Windows 10 pro, with NTFS. I think the filesystem is fully case-sensitive. I can have the file Bill_and_Ted.txt in a directory, and write scripts that won't mistake it for bill_and_ted.txt. Linux WSL apps accessing NTFS directories are fully case-sensitive. But it seems that Windows utilities get confused.

So NTFS is probably case sensitive, but perhaps Windows is not. Is it possible in Windows to create two files in the same directory that only differ in ASCII case?

For various software development reasons, I would like to have the files Bill_and_Ted.txt and bill_and_ted.txt in the same directory, and then change the content. But so far, Powershell Copy-Item and Windows xcopy refuse to copy to the same directory when the filenames differ only in case. They fail with "File cannot be copied onto itself"

Is there a built-in Windows way to copy to the same directory and only change the case of the filename?

Charlweed
  • 209
  • 2
  • 12

3 Answers3

3

This may be helpful.

https://superuser.com/a/412413/1176865

Go to the directory and run the following command:

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

Here is the break-down in case someone wants to modify/improve :

  • for /f - For every line
  • "Tokens=*" - Process each item in every line.
  • %f in (...) - %f is your variable name for every item.
  • dir - lists every file and subdirectory in a directory.
  • /l - (parameter for dir) Uses lowercase.
  • /b - (parameter for dir) Uses bare format, only the file/directory names, no size, no headers.
  • /a-d - (parameter for dir) Do not list directories. (a stands for attribute, - stands for not and d stands for directory).
  • rename "%f" "%f"- rename the file with its own name, which is actually lowercased by the dir command and /l combination.
Evan Anderson
  • 141,071
  • 19
  • 191
  • 328
1

The Short answer is, as long as you are using windows it will not work. Windows API does not support case sensitive.

in reference to : https://stackoverflow.com/questions/33998669/windows-ntfs-and-case-sensitivity

djdomi
  • 1,377
  • 3
  • 10
  • 19
0

A solution is to use the fsutil to enable the setCaseSensitiveInfo flag on the containing directory. So in my case, I Set-Location to the destination directory, then used:

fsutil.exe file setCaseSensitiveInfo (Get-Location) enable

HowToGeek article explaining setCaseSensitiveInfo flag

Thanks for this stackoverflow answer!

Charlweed
  • 209
  • 2
  • 12