Long Paths on Windows

When you create a file path with Windows, you are limited to a length of MAX_PATH, which is defined as 260 characters.

That limitation was removed in Windows 1607 (Anniversary Update) released in July 2016. Now you can have a path with 32,767 characters. Each component of the path (directory/file name) can be at most 255 characters.

To enable long paths, open a PowerShell window and type:

sp HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled 1

The setting will apply to any process started after you enable long paths.

Let’s see this in action. This PowerShell script takes the opening crawl of Star Wars and creates a directory for each line. Open a new PowerShell window to ensure you have the long paths enabled setting. Copy and paste this script:

$crawl = @"
Episode IV
It is a period of civil war.
Rebel spaceships, striking
from a hidden base, have won
their first victory against
the evil Galactic Empire.
During the battle, Rebel
spies managed to steal secret
plans to the Empire's
ultimate weapon, the DEATH
STAR, an armored space
station with enough
power to destroy an entire
Pursued by the Empire's
sinister agents, Princess
Leia races home aboard her
starship, custodian of the
stolen plans that can save
her people and restore
freedom to the galaxy...
$crawl -replace "[.']", "" -split "\n" |%{$d = $_.trim(); md $d -f; cd $d}
write-host "PATH LENGTH IS $((pwd).path.length)" -ForegroundColor Green