none
Length RRS feed

  • Question

  • How do I show the files greater than 260 characters to edit them?
    Get-ChildItem -Path $pathToScan -Recurse -Force | Select-Object -Property LastWriteTime, FullName, @{Name="FullNameLength";Expression={($_.FullName.Length)}}
    Saturday, January 9, 2016 3:03 PM

Answers

  • The Fail is that not read subdirectories/files.

    Dir: d:\files\files01\test.log

    WARNING: Cannot find path 'FILES01' because it does not exist

    Sunday, January 10, 2016 7:22 PM

All replies

  • Get-ChildItem -Path $pathToScan -Recurse -Force | Where{$_.length -gt 260}


    \_(ツ)_/

    Saturday, January 9, 2016 5:37 PM
  • That already tried it, but gives error and does not show it


    Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
    At line:4 char:1
    + Get-ChildItem -Path $path -Recurse -Force | Where{$_.length -gt 260}
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ReadError: (DIR\FILE:String) [Get-ChildItem], PathTooLongException
        + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand

    Saturday, January 9, 2016 7:58 PM
  • You cannot fix that.  "Path Too Long" is fatal.

    Search for tools to manage long paths.

    Length here is about the size of the file and not the path. Any file that is too long will throw an error before you before you can access it.

    Suggest: list all files using robocopy list to file and get lengths from robocopy log file.


    \_(ツ)_/

    Saturday, January 9, 2016 8:03 PM
  • Thank you. I'm going to try it
    Saturday, January 9, 2016 8:04 PM
  • I have seen this script, but I am unable to give any result.
    https://gallery.technet.microsoft.com/scriptcenter/Get-Deeply-Nested-Files-a2148fd7

    Command: .\Get-FolderItem.ps1 -Path $Path -MaxAge 260
    Sunday, January 10, 2016 5:14 PM
  • Please take the time to read the instructions.  You are just guessing.  The first page is explicit in how to use this.

    If you continue to have issue with items in the Gallery the item has a support page:

    https://gallery.technet.microsoft.com/scriptcenter/Get-Deeply-Nested-Files-a2148fd7/view/Discussions#content


    \_(ツ)_/

    Sunday, January 10, 2016 5:27 PM
  • Hi JRV

    I have read.
    First charge in memory:  . path>\Get-FolderItem.ps1
    Then I run the command.  Get-FolderItem.ps1 -Path $Path -MaxAge 260

    Sunday, January 10, 2016 5:36 PM
  • You are not calling the function.

    Please, please, please take some time to learn the basic of PowerShell.  U ask the exact same question over-an-over-and-over again. 

    The Gallery code is supported in the Galery on the linked Q&A page.  That I where you ask questions of the author.

    How to use basic PowerShell is here: http://blogs.technet.com/b/heyscriptingguy/archive/2015/01/04/weekend-scripter-the-best-ways-to-learn-powershell.aspx

    You need to learn  how to load PS files and how to call functions:

    http://blogs.technet.com/b/heyscriptingguy/archive/2009/12/23/hey-scripting-guy-december-23-2009.aspx


    \_(ツ)_/

    Sunday, January 10, 2016 5:42 PM
  • Here is how to filter for the length:

    Get-FolderItem |?{$_.fullpathlength -gt 250}


    \_(ツ)_/

    Sunday, January 10, 2016 6:01 PM
  • Thank you for your help. I have implemented this script.

    #Load the Get-FolderItem function into the session
    cd H:\ScriptsPS
    . ./Get-FolderItem.ps1


    # Set Paths
    $path = "D:\Files"
    $outputfolderpath = "D:\tmp\"

    $GetRootFolder = Get-ChildItem -path $path | ?{ $_.PSIsContainer }
    foreach ($folder in $GetRootFolder)
    {
    $outputfile = ($outputfolderpath + $folder.Name + '_FilesPaths.csv')
    (Get-FolderItem -Path $folder.FullName | Where-Object {$_.FullPathLength -gt 250})| Export-CSV "$outputfile"
    }

    Sunday, January 10, 2016 6:07 PM
  • This is more likely to work:

    $path = 'd:\files'
    $outputfolder = 'D:\tmp'
    $maxpath=260
    
    Get-ChildItem $path -Directory |
    	ForEach-Object{
    		$outputfile = [io.path]::Combine($outputfolder, ($_.Basename + '_FilesPaths.csv'))
    		Get-FolderItem $_ | 
    			Where-Object { $_.FullPathLength -gt $maxpath } | 
    			Export-CSV $outputfile -NoTypeInformation
    	}
    


    \_(ツ)_/

    Sunday, January 10, 2016 6:23 PM
  • It is rare. It does not create the log...
    Sunday, January 10, 2016 6:38 PM
  • The Fail is that not read subdirectories/files.

    Dir: d:\files\files01\test.log

    WARNING: Cannot find path 'FILES01' because it does not exist

    Sunday, January 10, 2016 7:22 PM
  • Read this first:

    This forum is for scripting questions rather than script requests


    -- Bill Stewart [Bill_Stewart]

    Monday, January 11, 2016 3:07 PM
    Moderator