Or you can simply use the following Registry change. You can activate it via the Group Policy editor if you have a version of Windows with that. Interestingly, PowerShell has support built in so enabling this option will allow long paths to be used directly in PowerShell scripts. It is not, at the time of writing, activated by default since it requires specific application support. This is an option that has been added to recent versions of Windows 10. Reference: (v=vs.85).aspx#maxpath Long path support Note that some, poorly written but sadly quite common, applications do not support UNC file paths nor the long path prefix. You can combine this with the long path prefix so: \\?\UNC\server\share UNC names are normally used when referring to paths on remote servers in the form \\servername\path name\file name. The prefix used to tell the API to use long Unicode paths is \\?\ as in: \\?\D:\very long path This is often mistakenly referred to as UNC naming but it isn't though it is related. The Windows API has a special function that supports Unicode path names up to 32k characters long (each element being up to 255 characters in length).
Only software with an appropriate manifest entry will be able to make use of this. With Windows 10, you can enable long path support for general use - note however, that not all applications will work with long paths, you should test older software.You can use extended length path prefix to access long paths.There are two things not already mentioned in the existing answers. You may need to go through this process more than once to get rid of all of the files.
How to delete a file in Windows with a too long filename? PS: I realize this answer was here, less didactically. (Taken from "Path too long? Use Robocopy" by BVLANGEN)
Since there are no files or folders in the source directory ( C:\emptyfolder), it simply deletes the files and folders under the target directory ( C:\delete\this folder\with a very long name) recursively!įinal trick: you can avoid writing by hand C:\delete\this folder\with a very long nameīy dragging the folder from an Explorer window and dropping in the Terminal/cmd window.īe careful: The deleted files will not go to the trash folder! Once deleted, the files cannot be recovered. mkdir C:\emptyfolderĬopy+update from the empty directory to the target, using the option /purge robocopy c:\emptyfolder "C:\delete\this folder\with a very long name" /purgeĭelete the empty directory. Let’s say the target for deletion is: C:\delete\this folder\with a very long nameįirst create an empty directory, f.i. Just open the search in Windows, type cmd and hit Enter.
These instructions are for the command line.
There is no need to install any program for solving this issue. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.ĭoes anyone know of any tools or easy ways to get around this delete error without having to manually find the problem files and move/rename them? Trying Remove-Item in powershell gives the following error: Remove-Item : The specified path, file name, or both are too long. If I try deleting the directory from Explorer I get the error Cannot delete : The file name you specified is not valid or too long.
And I'm trying to avoid any manual process (other than triggering a single command) to actually delete them. This is the same errors this question, but the answers there don't really work for me as I'm dealing with a directory, not a file, and I don't always know what specific files or subdirectories are causing the problem.
Our ant script is somehow able to delete them when doing a clean, but sometimes I need to delete the workarea directory (where all the temp files go) without actually doing a full clean from ant. Our build process creates a number of temporary files (many build off of a WSDL) that run afoul of this limit. Windows seems to have a length limit on file names when trying to delete, though it won't prevent those files from being created.