[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

5 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

Leave a Reply