• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
OpenTechTips

OpenTechTips

Comprehensive IT Guides for Pros and Enthusiasts

MENUMENU
  • HOME
  • ALL TOPICS
    • Exchange
    • InfoSec
    • Linux
    • Networking
    • Scripting
      • PowerShell
    • SSL
    • Tools
    • Virtualization
    • Web
    • Windows
  • ABOUT
  • SUBSCRIBE
Home » Dealing With SUPER LONG file path in Windows

Dealing With SUPER LONG file path in Windows

June 10, 2020 - by Zsolt Agoston - last edited on June 10, 2020

After abandoning the 8.3 file name limitation (pre-Win95 all files had a max name length of 8 characters, and a 3-char long extension), the Windows Win32 API allowed whole file paths to be as long as 260 characters long. However, in modern file systems that limit is often met and exceeded as users are nesting more and more folders into each other, causing very long file paths to form. Once it is reached, files operations (move, copy, rename) will throw an error message stating the file path is too long.

Dealing With SUPER LONG file path in Windows

Command line fix

To get around the issue we take advantage of the NTFS file system supporting 32,767-character long filepaths. To get around the Win32 API limitation we use the '\\?\' prefix, that can be used in front of either a local or a UNC path. This prefix tells the API to stop parsing the input string and send it as it is to the operating system. This way even the quote and double-quote characters are allowed in filenames, that cause issues when the file path is parsed. See examples:

ls -LiteralPath '\\?\C:\[Very long path]\test.txt ' -Recurse
ls -LiteralPath \\?\UNC\EDGE.alwayshotcafe.com\C$\[Very long path]\test.txt

Assign a drive letter to a path

If you stick with the good old CMD line, you can always shorten the path by assigning the path a drive letter. Use the 'net use' or 'subst' commands.

Example:

subst X: "C:\temp\CentOS\from\Community\Enterprise\Operating\System\is\a\Linux\distribution\that\provides\a\free\community-supported\computing\platform\functionally\compatible\with\its\upstream\source\Red\Hat\Enterprise\Linux\RHEL\In\January\2014\CentOS\the"

:: or use net use, that requires a UNC path as the input:

net use X: "\\localhost\C$\temp\CentOS\from\Community\Enterprise\Operating\System\is\a\Linux\distribution\that\provides\a\free\community-supported\computing\platform\functionally\compatible\with\its\upstream\source\Red\Hat\Enterprise\Linux\RHEL\In\January\2014\CentOS\the"
Dealing With SUPER LONG file path in Windows

Now you can copy, rename, move your files, folders as needed. When you finish don't forget to remove the drive mapping.

subst X: /d

:: or

net use X: /d

Registry Fix - for all Windows editions

To enable long filepath support, a simple Registry edit is needed. Add the LongPathsEnabled double word value to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem and make sure it's set to 1.

Dealing With SUPER LONG file path in Windows

Set Long Path support with Group Policies

Windows 10, 2016 and later Pro editions have a built-in GP object that accomplishes the same thing. You can find it under "Computer Configuration > Administrative Templates > System > Filesystem", called "Enable Win32 long paths". Set it to 'Enabled'

Dealing With SUPER LONG file path in Windows

Reader Interactions

Comments

  1. Michael Jagger says

    October 11, 2024 at 10:16

    What is the best way to solve the “File name too long” issue when trying to rename or move files in Windows?

    Reply

Comments Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tools

Secondary Sidebar

CONTENTS

  • Command line fix
  • Assign a drive letter to a path
  • Registry Fix – for all Windows editions
  • Set Long Path support with Group Policies

  • Terms of Use
  • Disclaimer
  • Privacy Policy
Manage your privacy

To provide the best experiences, we and our partners use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us and our partners to process personal data such as browsing behavior or unique IDs on this site and show (non-) personalized ads. Not consenting or withdrawing consent, may adversely affect certain features and functions.

Click below to consent to the above or make granular choices. Your choices will be applied to this site only. You can change your settings at any time, including withdrawing your consent, by using the toggles on the Cookie Policy, or by clicking on the manage consent button at the bottom of the screen.

Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}
Manage your privacy
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Statistics

Marketing

Features
Always active

Always active
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
Manage options
{title} {title} {title}