[Fix] Source Path Too Long while deleting files

I have extracted a backup file of WordPress website (from Linux server) on Windows desktop. But when I try to delete the folder, I get this error message:

Source Path Too Long 
The source file name(s) are larger than is supported by the system. Try 
moving to a location which has a shorter path name, or try renaming to 
shorter name(s) before attempting this operation.

Source Path Too Long

Then, I try to find which folder/file that caused this problem, and found out that they are in a cache folder and Windows explorer cannot delete or rename these folders.
Cannot delete the file on Windows

Solution

This error occurs because Windows explorer can’t handle any file or folder that has full path longer than 255 characters. In this article, I will show 2 methods to delete files or folders that have source path too long issue.

  1. Use subst command to shorten a full path
  2. Delete long path files with 7-Zip

Watch on YouTube

Step-by-step

Use subst command to shorten a full path

You can use subst command to map a path with a drive letter in order to shorten full path. In this example, I will map this path – C:\Users\linglom\Desktop\public_html\wp-content\cache to z:\

  1. Copy a path that you want from the address bar on Windows Explorer.
    Copy path from Windows Explorer
  2. Open Command Prompt by right-click Windows icon at bottom left and select Command Prompt.
    Open Command Prompt
  3. Type this command and press Enter.
    subst z: C:\Users\linglom\Desktop\public_html\wp-content\cache

    Note: You have to replace path to a folder that you’re having the problem. You can also replace z: with other drive letter that available on your system.
    Map path to a drive with subst command

  4. Open Windows Explorer and browse to Z:\. You can now delete or rename these files.
  5. When finishes, you can remove this virtual drive by type this command.
    subst z: /d

    Delete a virtual drive with subst command

Delete long path files with 7-Zip

You can use 7-Zip File Manager to handles long path folders and files.

  1. Download and install 7-Zip from http://www.7-zip.org/download.html.
    Download 7-Zip
  2. Open 7-Zip File Manager.
    Open 7-Zip File Manager
  3. Browse to a path that you can see the folder that you want to delete. Select the folder and press Shift + Delete to delete a folder instantly (without moving it to recycle bin)
    Note: Make sure that you select a folder that you really want to delete before proceed.
    Delete a folder on 7-Zip File Manager
  4. Click OK to confirm.
    Confirm deleting a folder

35 Comments

  1. Russell April 26, 2017
  2. Liam May 19, 2017
  3. Bettyann Mullis May 21, 2017
  4. Aden Brooklyn May 31, 2017
  5. Ashley100 June 22, 2017
  6. Joshua Brigs January 13, 2018
  7. Fred Smith January 16, 2018
  8. Andrew Jobel March 1, 2018
  9. Jurgen Parker March 15, 2018
  10. Ross Gram May 8, 2018
  11. David Galler July 19, 2018
  12. Brandon Wooten August 5, 2018
  13. Kalle Koenig September 27, 2018
  14. Tim Drayk August 22, 2019
  15. Steve September 6, 2019
  16. Peter Smith November 23, 2019
  17. Peter harper January 13, 2020
  18. samuel February 12, 2020
  19. Patrick April 14, 2020
  20. Damien Brock May 8, 2020
  21. Hila May 14, 2020
  22. Eniela May 18, 2020
  23. Valdemar Bago May 28, 2020
  24. damienbrock June 8, 2020
  25. Juan Miller June 30, 2020
  26. Mark Track July 1, 2020
  27. Frank Gleg July 21, 2020
  28. damien brock August 7, 2020
  29. Sagar June 11, 2021
  30. Indra June 28, 2021
  31. George Kim August 6, 2021
  32. Pramod March 18, 2022
  33. Pramod Nair March 18, 2022
  34. Adam Gore September 1, 2024
  35. dhie October 21, 2024

Leave a Reply