Quantcast
Channel: Total Commander
Viewing all articles
Browse latest Browse all 18761

Eng :: RE: Scan to find length of path/file names?

$
0
0
Author: Stefan2
Subject: PowerShell: Scan to find length of path/file names?
Posted: Thu Nov 10, 2016 8:23 am (GMT -6)

spikey wrote:
Is it possible to use TC to scan to find path\file names which exceed a certain value.

For example, I want to list all path\file names over 255 characters within a particular directory.


Depending on what to do with the result, I would do it perhaps with PowerShell:


Code:

PS H:\temp>

PS H:\temp>dir -rec *.txt |select FullName, @{L="PathLen";E={($_.FullName).Length}}|sort PathLen -desc|Export-Csv zzzPathLen.csv

PS H:\temp>



zzzPathLen.csv
Code:

H:\temp\NewFileFromTemplate\ShellNew\%Y-%m-%d Work folder structure\Sub Folder1\01 Order\%Y-%m-%d_KONTAKT.txt,"109"
H:\temp\SubFolders\SubFolder-01-03\Sub03Folder-01-01\Sub03Folder-Sub01\Space between lower upper regex.txt,"106"
H:\temp\PS\Encode2UTF8\sub folder\List of Zwei- drei-stellige Namen Songs music.txt.orig.txt,"92"
H:\temp\PS\Encode2UTF8 - Kopie\sub folder\List of Zwei- drei-stellige Namen Songs music.txt,"91"
H:\temp\001 space\_ aaaa TEST AllowedChars03  '   Apostrophe (single quotation mark) #.TXT,"90"
H:\temp\AutoHotkey 1.0.48.05_(30-Sep-2013)-TESTS\Extras\Editors\UltraEdit\Separators.txt,"88"




- - -

Clarifying:

dir -rec *.txt |
select FullName, @{L="PathLen";E={($_.FullName).Length}} |
sort PathLen -desc |
Export-Csv zzzPathLen.csv


Get-ChildItem -Recurse *.txt |
Select-Object FullName, @{   Label="PathLen"; Expression={($_.FullName).Length}   } |
Sort-Object PathLen -Descending |
Export-Csv zzzPathLen.csv


- - -

Alternative:

Get-ChildItem -Recurse *.txt |
Select-Object FullName, @{ Label="PathLen"; Expression={($_.FullName).Length} } |
Sort-Object PathLen -Descending |
Select-Object -First 15 |
Export-Csv zzzPathLen.csv

or rather:

Get-ChildItem -Recurse *.txt |
Select-Object FullName, @{ Label="PathLen"; Expression={($_.FullName).Length} } |
Sort-Object PathLen |
Select-Object -Last 15 |
Export-Csv zzzPathLen.csv


Just an idea Cool
 
_________________
MfG, Stefan

Am Anfang war das Wort... Darum: Wehret den Anfängen. Kein Viertes Reich! - (☪ oe is †) = ☮


Viewing all articles
Browse latest Browse all 18761

Trending Articles