www.gsx.com | log in | register

Last update: . Author: Christian Stokes .

How to Clean Folder Contents when a Filename or File Path is to long

When cleaning files from a Windows Operating System (OS), you are halted with errors relating to the filename or the file path being too long. This is due to a 255/260 character limit on Windows Operating Systems preventing the files in a directory from being removed.

Follow this article to learn how to remove all files from a directory that have a longer than allowed filenames or paths by using the Microsoft utility "Robust File Copy" (Robocopy).

Windows 7+

Symptoms

  • Source Path Too Long
  • The source file name(s) are larger than is supported by the file system. Source_Path_Too_Long.PNG

How to Solve the Issue

The actions performed in the below process will permanently remove all contents, such as files and folders, in your specified path.

Using Robocopy to delete files that have a path and filename that is too long:

  1. Notate the folder directory path that needs its contents to be deleted.
    • Example: C:\FolderToBeCleaned
      FolderToBeCleaned_Contents.PNG
  2. From Windows File Explorer, create an empty folder anywhere on the hard drive:
    • Example: C:\EmptyFolder
  3. Open a Windows Command Prompt as an Administrator.
  4. Type the following command, replacing the example paths with yours:
    • Robocopy C:\EmptyFolder C:\FolderToBeCleaned /purge
      Robocopy_Command_ran.PNG
  5. Press the Enter key.

 

The folder contents are now deleted:

FolderToBeCleaned_empty.PNG

 

 


Was this article helpful?

179 out of 227 found this helpful




Not finding what you are looking for?

Have more questions? Submit a request