Dealing With Long File Names

by Apr 14, 2016

The Windows file system often has issues with file paths longer than 256 characters. Provided you followed our tips and installed PowerShellGet, you can easily download a PowerShell module with new cmdlets that help overcome this limit:

 
PS> Install-Module -Name PSAlphaFS -Scope CurrentUser

PS> Get-Command -Module PSAlphaFS | Select-Object Name, Version

Name              Version
----              -------
Copy-LongItem     1.0.0.0
Get-LongChildItem 1.0.0.0
Get-LongItem      1.0.0.0
Move-LongItem     1.0.0.0
New-LongItem      1.0.0.0
Remove-LongItem   1.0.0.0
Rename-LongItem   1.0.0.0 
 

The cmdlets in this module all accept paths longer than 256 characters. However, keep in mind that this is a free and open source module, so it has its quirks. The commands will bail out once they come across an "access denied" error, and Get-LongChildItem won't emit results in real-time.

The cmdlets in this module really are functions, so if you'd like to take a look at the source code and see what you can improve, try this:

${function:Get-LongChildItem} | clip

This line would copy the source code from Get-LongChildItem to your clipboard. Just paste the code into your favorite editor afterwards.

Twitter This Tip! ReTweet this Tip!