@ECHO OFF Title delete_file_folder_fast_simple_robocopy_v2.bat REM v2a REM Description: Use parameters or drag and drop to fast delete a file or folder REM Uses Robocopy for folders, DEL command for files. Limited to one file or folder REM Asks for confirmation before delete. No output displayed for deletions REM Ref: http://mattpilz.com/fastest-way-to-delete-large-folders-windows/ REM Ref: https://superuser.com/questions/416071/how-to-delete-huge-number-of-files-on-windows REM change to current directory pushd "%~dp0" REM ---------------- set path for RoboCopy if required ---------------------- REM set path="F:\Utilities\commandlinetools\backup_copy_utilities\robocopy";%path% REM ------------------------------------------------------------------------- REM Remove existing EmptyDir If exist "%~dp0EmptyDir" RMDIR /Q "%~dp0EmptyDir" REM Test for empty parameter IF [%1] == [] ( ECHO. ECHO ------------------------ No files or folders to processs ------------ ECHO No file or folder detected ECHO Press any key to exit and restart again ... pause>nul & exit /B 0 ) REM Use pushd to cd to parent directory REM (workaround for UNC path to network drives) SET PARENT=%~1\.. pushd "%PARENT%" REM Test if parameter is a file or directory set ATTR=%~a1 set DIRATTR=%ATTR:~0,1% if /I "%DIRATTR%"=="d" ( REM Create an empty directory call :askdelete "%~n1%~x1" MKDIR "%~dp0EmptyDir" robocopy "%~dp0EmptyDir" "%~1" /MIR /W:0 /R:0 >NUL RMDIR /Q "%~1" REM Remove empty directory RMDIR /Q "%~dp0EmptyDir" goto end ) REM Delete file call:askdelete "%~nx1" DEL /F/Q "%~1" >NUL :end popd EXIT /B 0 :askdelete ECHO. ECHO Delete: "%~1" ECHO From: "%~dp1" ECHO. ECHO Press any key to delete. To quit, click the X on on this window or use CTRL + C ... PAUSE >NUL goto:eof