When you try to copy or transfer the file, where the characters count for that file path is more than 260 characters, then you receive an error message such as destination path too long. In the windows file naming system, the complete filename path cannot exceed the 256 characters. This includes the folder path, filename, and file extension. If it exceeds, and you have to try to delete it, immediately you will receive the below error The file name(s) would be too long for the destination folder, you can shorten the file name and try again, or try a location that has a shorter path.
Maximum Path Length Limitation
In the latest version of the Windows Operating system, filename could be 255 characters long, and file path length goes up to 32,767 characters long but in Win API, the maximum length of MAX_PATH variable restricts filenames and file paths to under 260 characters. We cannot change the MAX_PATH value because other system variables depend on them.
How to fix it?
These solutions are applicable not only for Windows Client families Windows 7, Windows 8, Windows 10, and Windows Server families like Windows Server 2003, Windows Server 2008, and Windows Server 2012R2/2016/2019 operating systems.
Solution 1: Rename the file
When you getting an error, this will prompt you, what filename is causing this issue or path of that file. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For Example
Let’s find the file in Windows Explorer, hit F2 to rename it, and give the shorter file name. your problem could be solved. It could possible when you opened that file path and tried to rename or delete the file. you don’t get the option to choose either. Then you have to move forward to the next solution.
Solution 2: Install 7 Zip compression Utility
- Click on 7-Zip to download this compression utility from the internet.
- Right-click on file and open with 7-Zip compression utility.
- Now, try to delete it. your problem will be gone.
If you don’t want to install 7-Zip compression utility, then skip to the next solution.
Solution 3: Use built-in command-line Subst
- To open Command Prompt with administrative privileges, Press Win key, and type cmd and then click “Run as Administrator.
- Type below command in command windows.
Subst k: [full long path of the folder where the file exists which you want to delete]
- Press Enter
- Once done you can delete the virtual disk using the below command.
Subst K: /d
It will shorten your file path and create a virtual disk named K drive. Then you can open the path in K drive and delete the file from there.
Solution 4: Permanently Windows 10 Accept Long File Paths
If you have permanent requirements and going to use long file names and long file paths, it is better to do make changes in registry settings, and make Windows 10 to accept long file paths.
Note: Always make a backup to make any changes in registry settings, let’s open the registry editor.
- Press Win+R key, type REGEDIT in ‘RUN’ dialog box, and press enter key.
- Once you have registry editor opened, navigate to the location and find the key LongPathsEnabled
- Right-click on LongPathsEnabled DWORD key and select Modify.
- In the value data field, set the value to 1 and click on OK to commit the changes.
- Close the Registry Editor and now you would able to work with a long file path now.
These are a few simple tricks, that work perfectly. There are some other ways to solve the error. The file name would be too long for the destination folder, but I have gone through the simplest method. Checkout more tech-related articles.
We hope you like this article helpful. For more tech-related content you can explore the complete website or you can reach out to our YouTube channel iTechBestPractices
I am thanking you to visiting our website