05 January 2018

Recursively delete files in Windows



Recursively delete files in a folder with long file names:

robocopy /MIR D:\temp\empty D:\folder\with\long\names

robocopy will recursively copy files. But with /MIR switch, there is an attempt to mirror source folder to destination folder.

If destination folder is having files with long file names and is getting difficult to delete, you can force it to mirror an empty folder which will recursively delete it in an attempt to mirror an empty folder.

Neat trick.

Source : http://clintboessen.blogspot.com.au/2014/05/how-to-delete-files-which-exceed-255.html