Friday, August 22, 2014

windows - Count the Number of Characters in a Full FIle Path?


I need to be able to count the number of characters in a full path to a file in windows. How I am currently accomplishing this task is as follows:



  1. Open a command prompt

  2. cd to the directory in question (for example c:\CruiseControl\ProjectArtifacts\ProjectName)

  3. type the following command
    dir /s /b > output.csv

  4. Open the resulting output.csv file in excel.

  5. use the =LEN() function in excel to count the number of characters per row as listed in the output.csv file.


Does anyone know of an explorer shell extension, or some 3rd party tool that could preform this function without me having to manipulate the output from dir in excel? Is there some easier way to go about doing this? The root of the issue I am having is the ~260 character file path limit in Windows. I am trying to analyze which paths are approx ~260 characters so I can shorten them to avoid getting this error.


Answer



This kind of thing is very easy to do with Hamilton C shell. If this a one-time thing, you'll be happy with the free version. Here's an example generating the fullpaths of several files in the c:\Windows directory, then computing the string lengths. Full disclosure: I'm the author.


128 C% cd
c:\Windows
129 C% ls mi*
Microsoft.NET Minidump mib.bin
130 C% foreach i ( mi* )
131 C? @ f = fullpath ( i )
132 C? echo $i $f $strlen(f)
133 C? end
mib.bin c:\Windows\mib.bin 18
Microsoft.NET c:\Windows\Microsoft.NET 24
Minidump c:\Windows\Minidump 19
134 C%

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...