File path length?

General discussion related to "Everything".
Post Reply
CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

File path length?

Post by CrxtJ7tOs4Iq » Fri Mar 16, 2018 6:35 pm

I see there is a way to search based on name length(len:<length>), is there a way to do this on full path instead of just file name?
I am basically wanting a tool to find where the paths are to long for ntfs.

NotNull
Posts: 2343
Joined: Wed May 24, 2017 9:22 pm

Re: File path length?

Post by NotNull » Fri Mar 16, 2018 7:35 pm

Nice idea!

Don't think that this is possible in Everything.
But if you combine the powers of Everything with those of Powershell, you have a workaround:
  • In Everything query what you want (for exampl, only Q:\data or exclude C:\Windows, ...)
  • Export these results as a txt file (example: AllFiles.txt
  • In Powershell, issue this command:

    Code: Select all

    gc .\AllFiles.txt | where -property length -gt 255 | Out-File .\TooLong.txt
    
In TooLong.txt are your long filenames (including path).


BTW: 255 isn't really too long. Ifyou address the fil in a Win32 way instead of the DOS-way:
\\?\C:\enormous\long\path\including\filename.txt can be addresseed this way.

PS: Not tested. Please report back if this works or not.

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Fri Mar 16, 2018 9:24 pm

Awesome.... i already used powershell and everything command line for another project. Good thinking... will test early next week.
Will try my best to report back but i forget these things sometimes.

therube
Posts: 2728
Joined: Thu Sep 03, 2009 6:48 pm

Re: File path length?

Post by therube » Fri Mar 16, 2018 10:58 pm

Adjust len: as needed.

Code: Select all

path:len:>254

NotNull
Posts: 2343
Joined: Wed May 24, 2017 9:22 pm

Re: File path length?

Post by NotNull » Sat Mar 17, 2018 10:42 am

therube wrote:Adjust len: as needed.

Code: Select all

path:len:>254
Very nice!!


@CrxtJ7tOs4Iq:
Normally I do test such things before posting, but this time I was in a real hurry (after rereading: even more typo's than usual ..)
Of course you should go with @therube's solution, but if you need something similar for one of your projects: I've tested it and it works OK.
If you want output to file *and* screen (system looked dead for too long), use Tee -file .\TooLong.txt instead of Out-File .\TooLong.txt
You don't need the ES.exe command-line utility to export; that can be done in Everything itself through Menu:File > Export ..

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Mon Mar 19, 2018 3:10 pm

Awesome!

Thanks

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Tue Mar 20, 2018 3:16 pm

NotNull wrote: BTW: 255 isn't really too long. Ifyou address the fil in a Win32 way instead of the DOS-way:
\\?\C:\enormous\long\path\including\filename.txt can be addresseed this way.
Trying to use this example with anything Powershell. While it doesn't error. It doesn't seem to work.
Having a hard time finding additional information.

example get-acl '\\?\C:\enormous\long\path\including\filename.txt'

NotNull
Posts: 2343
Joined: Wed May 24, 2017 9:22 pm

Re: File path length?

Post by NotNull » Tue Mar 20, 2018 4:06 pm

CrxtJ7tOs4Iq wrote:
NotNull wrote: BTW: 255 isn't really too long. Ifyou address the fil in a Win32 way instead of the DOS-way:
\\?\C:\enormous\long\path\including\filename.txt can be addresseed this way.
Trying to use this example with anything Powershell. While it doesn't error. It doesn't seem to work.
Having a hard time finding additional information.

example get-acl '\\?\C:\enormous\long\path\including\filename.txt'
I don't have enormous long paths, but this works for me:

Code: Select all

PS C:\temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.16299.248
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.248
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


PS C:\temp> get-acl '\\?\C:\Windows\System32\drivers\etc\hosts'


    Directory: \\?\C:\Windows\System32\drivers\etc


Path  Owner               Access
----  -----               ------
hosts NT AUTHORITY\SYSTEM NT AUTHORITY\SYSTEM Allow  FullControl...

PS C:\temp> copy  '\\?\C:\Windows\System32\drivers\etc\hosts' .
PS C:\temp> ls hosts


    Directory: C:\temp


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        16-7-2016     13:45            824 hosts

PS C:\temp>
No idea why it dowsn't work in your case ...

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Tue Mar 20, 2018 5:21 pm

NotNull wrote:
CrxtJ7tOs4Iq wrote:
NotNull wrote: PS C:\temp> $PSVersionTable
No idea why it dowsn't work in your case ...
good call on the PS version.
I was using 3... appears to work when tested on 5.

Thanks!

NotNull
Posts: 2343
Joined: Wed May 24, 2017 9:22 pm

Re: File path length?

Post by NotNull » Tue Mar 20, 2018 6:34 pm

CrxtJ7tOs4Iq wrote: good call on the PS version.
I was using 3... appears to work when tested on 5.

Thanks!
You're welcome! Luckily it was the vrsion; otherwise I had no clue ..
Thanks for feedback!

BTW: did you bas64 encode your username? (m'N*)

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Tue Mar 20, 2018 6:37 pm

NotNull wrote:
CrxtJ7tOs4Iq wrote: BTW: did you bas64 encode your username? (m'N*)
Heh.... no....
it was just randomly generated.

NotNull
Posts: 2343
Joined: Wed May 24, 2017 9:22 pm

Re: File path length?

Post by NotNull » Tue Mar 20, 2018 6:42 pm

CrxtJ7tOs4Iq wrote: Heh.... no....
it was just randomly generated.
Nice coincidence...
Think I'll try this as a "password generator" ... password "Pasword" > base64 encoded: "UGFzc3dvcmQ=".
Easy to remember, hard to crack (well, until now, that is :D )

Good luck with your long file paths!

CrxtJ7tOs4Iq
Posts: 28
Joined: Wed Jan 14, 2015 2:19 pm

Re: File path length?

Post by CrxtJ7tOs4Iq » Tue Mar 20, 2018 8:48 pm

NotNull wrote: Good luck with your long file paths!
man that \\?\ trick is sweet! makes me not really care.

Will rewrite my powershell script that is auditing permissions and all will be good.

Thanks again

Post Reply