Friday, 3 August 2012

Solving the problem of 'path too long error' using O2 tool

Download: Util - View O2.Platform.Scripts file length v1.0.exe
View: Script Source Code

Amazingly in 2012 windows still complains for paths bigger than 240 chars. Now that O2 can be easily installed from a single exe, there is a normal case where O2 will be started from path that is a big long (lets say more than 100 chars). This created a problem since the O2 temp dir would be created from that  path , and there were a number of scripts that (since I like to use verbose file names) would break the 240 char limit (which would make the unzip of the O2.Platform.Scripts folder to fail).

So to help me solve this, I wrote a quick tool that gives me a quick view of what files are bigger than a particular size.

Here is the tool in action before I renamed a bunch of O2 files:

As you can see there were 198 files whose path was bigger than 120.

This tool (which you can download from here or see the source code below), has a number of nice features:
  • Slider to select the depth to filter the loaded files
  • Loads files once, which gives a nice real-time fell when moving the slider
  • Allows drag n' drop of folders to load all files from it
  • Auto filters/removes files in .git directories
  • Context menu (on the file list) to open the parent folder of the selected file and to reload the files
Here is a screenshot of what the O2.Platform.Scripts folder looks like now, after a number of script renames (which took me a couple minutes to do):

Script Source Code: