Get all files in folder including those with long (>256 characters) path + name

后端 未结 3 1317
别那么骄傲
别那么骄傲 2021-01-15 08:11

I\'m trying to build a comma separated list of file names in a specific folder. These files tend to have long names (they\'re test case results and the name is very descript

相关标签:
3条回答
  • 2021-01-15 08:51

    PowerShell v6.0.0-beta.3 and up now supports UNC paths by default; see my answer here for more information: https://stackoverflow.com/a/47046785/1599699

    0 讨论(0)
  • 2021-01-15 09:06

    This seems to be a really popular question because it has been asked multiple times on this site.Anyway here are your alternatives:

    Use Pinvoke

    Boe Prox - Technet

    Use Robocopy

    Boe Prox - Technet

    Use AlphaFS with Powershell V5 and V4

    if you can find a computer with PowerShell v5 (windows 10 comes with PS v5) you can install a module called PSAlphaFS .

    Install-Module PSAlphaFS
    

    by default the modules from powershellgallery get installed to

    C:\Program Files\WindowsPowerShell\Modules
    

    Note:The PSAlphaFS module can also be run on a target system with PowerShell V4 but not on powershell V3.

    Here is how you can find out the version of Powershell that is currently running.

    $PSVersionTable.PSVersion
    

    Once the module is in place you can then run the following command which is similar to get-childitem but without the 260 char limitation.

    Get-LongChildItem  -Filter *.txt -Name
    
    0 讨论(0)
  • 2021-01-15 09:12

    It appears there is no straightforward way to handle this situation using PowerShell. To me that means PowerShell is not the right tool for this job and I'm going to use my "work-around" cmd script instead.

    0 讨论(0)
提交回复
热议问题