Description

Because of a problem deleting long path and filenames I wrote a script which uses robocopy. Copy the source in a batchfile and for %1 use path or path to file to delete. You can use the script to delete single path/file or a complete pathstructure. You need robocopy installed for usage!

Source Code

@echo off 
if {%1}=={} @echo Syntax: DelFolder FolderPath&goto :EOF 
if not exist %1 @echo Syntax: DelFolder FolderPath – %1 NOT found.&goto :EOF

setlocal 
    set folder=%1 
    set MT="%TEMP%DelFolder_%RANDOM%" 
    MD %MT% 
    RoboCopy %MT% %folder% /MIR 
    RD /S /Q %MT% 
    RD /S /Q %folder% 
endlocal
1 Spice up

you may also want to check this freeware tool DeleteLongPath™ Delete Long Paths and Folders with Deep Structure above 240 Chars | BackupChain “DeleteLongPath” which also works from batch files if need be

I think this link can help you at the part of long path names https://community.spiceworks.com/topic/2250740-scanning-folders-with-robocopy?page=1#entry-8721029