DEV Community

EDDYMENS
EDDYMENS

Posted on

Getting your Windows files and folders to behave as on Linux

Windows,Linux

I will make this brief.

If you write software on a Windows machine but then usually deploy on a Linux server you probably have run into the trouble of your software breaking because of the difference in the way both OS handles file names and the issue with referencing the wrong case of the name in your code.

Basically you can get away with calling on index.js as Index.js on Windows but not on Linux.

To get your directories and files to behave on Windows as they would on Linux.
Open PowerShell navigate into your project directory and run the following script.

(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable}

This will enable case sensitivity for when you reference a name of a file/folder in your code or if namespacing depends on file and folder names like in PHP.

This way if you mix up the case of your file you won't be forgiven even on Windows because Linux won't either.
I got this script on Stackoverflow but I am still looking for the source.
I will add that bit when I find it.
I kept the above script in a Gist for when I need it and felt I should share it.
The End...

Top comments (0)