How to delete "The file name is too long." in windows. [Command Prompt] [closed]
To delete The file name is too long. errors files, we've to go for simple steps using default command of Windows robocopy
and rmdir
.
- Create directory
mkdir deleteLongFilesDir
underC:
orD:
drive - Suppose
D:\Development\Liferay\themes
directory contains the files which are not able to delete simply. - run command in command prompt
robocopy D:\deleteLongFilesDir D:\Development\Liferay\themes /purge
, this command will print some logs and copy you all the files and sub directory ofD:\Development\Liferay\themes
intodeleteLongFilesDir
folder virtually, but when you open that directory... hurreeee...It's Empty ??? - Now run the command of remove directory which we created for mapping
rmdir deleteLongFilesDir
from command line. - Now temporary directory has been deleted and same as for
D:\Development\Liferay\themes
files and folder.
There is a Powershell cmdlet named Remove-Item2, written by Boe Prox a well-known MVP, and which circumvents the basic limitation path of 260 characters.
https://gallery.technet.microsoft.com/scriptcenter/Remove-LongPathFile-7a4db495
Additionally, like Remove-Item2, there are other cmdlets suffixed by the number 2, like Get-ChildItem2, which are often included in popular third party modules, and also addresses the 260 characters limitation. If you have installed some of these modules, there is a chance that you have already those cmdlets on your computer.