@ECHO Off REM -- Prepare the Command Processor Setlocal Enabledelayedexpansion Title delete_files_folders_fast_v2.bat REM Description: Use parameters or drag and drop to fast delete files and folders REM Echos deleted folders, but not files REM Ref: http://mattpilz.com/fastest-way-to-delete-large-folders-windows/ REM change to current directory REM pushd "%~dp0" REM set path for external apps REM set path="C:\xxx\xxx";%path% REM set path="C:\xxx\xxx";%path% REM ---------------------------- set colors --------------------------------- REM Uncomment one option below to set REM Yellow on Black REM COLOR 0e REM White on Blue REM Color 1F REM Black on Yellow REM Color e0 REM Blue on Yellow REM Color e1 REM 0=Black,1=Blue,2=Green,3=Aqua,4=Red,5=Purp,6=Yellow,7=White,8=Gray,9=Lt Blue REM A=Lt Green,B=Lt Aqua,C=Lt Red,D=Lt Purp,E=Lt Yellow,F=Bright White REM ---------------------------- end colors ---------------------------------- ECHO Use parameters or drag and drop file^(s^) or folder^(s^) on this script ECHO to fast delete them ECHO. ECHO All files or folders to delete should be in the same directory ECHO. ECHO This script fast deletes files or folders but without an easy way to ECHO recover the contents^^^! ECHO. ECHO ------------------------- ECHO. 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 change to working directory CD "%~dp1" REM Test if FIRST parameter is a file or directory set ATTR=%~a1 set DIRATTR=%ATTR:~0,1% if /I "%DIRATTR%"=="d" ( ECHO First parameter is a folder: "%~n1%~x1" ECHO. goto next ) if /I "%DIRATTR%"=="-" ( ECHO First parameter is a file: "%~nx1" ECHO. goto next ) :next REM REMove absolute path SET FOLDER=%~n1%~x1 ECHO Folder/file attributes of above: %~a1 ECHO. REM Use pushd to cd to parent directory REM (workaround for UNC path to network drives) SET PARENT=%~1\.. pushd "%PARENT%" ECHO Delete from: %CD% ECHO. ECHO Delete the following files and/or Folders? FOR %%e in (%*) do ECHO %%~nxe ECHO. :begin ECHO To quit, press X on on this window or use CTRL + C ... ECHO. ECHO Press any key to delete the above file^(s^) and/or folder^(s^) ... PAUSE >NUL ECHO. set count=0 :Loop REM test parameters on each loop to identify folders from files IF [%1]==[] goto continue set ATTR=%~a1 set DIRATTR=%ATTR:~0,1% if /I "%DIRATTR%"=="d" ( DEL /F/Q/S "%~1" >NUL RMDIR /Q/S "%~1" ECHO Deleted folder: "%~nx1" ) else ( DEL /F/Q "%~1" >NUL REM Uncomment below to ECHO deleted files REM ECHO Deleted file: "%~nx1" ) :endloop set /A count+=1 SHIFT goto Loop :continue ECHO. ECHO Files and/or Folders processed: %count% popd ECHO. ECHO -------------------------- closing batch file -------------------------- ECHO. Endlocal ECHO. call:errorfunc ECHO. REM --------------------- Exit options (default is paused exit) ------------- REM Uncomment below to exit now REM goto end REM Uncomment below to use delayed exit goto delayedexit REM ---------------------------- Paused exit -------------------------------- ECHO.&ECHO.Press any key to end the application ... Pause>NUL&Goto:end REM ---------------------------- Delayed Exit -------------------------------- :delayedexit REM Sets exit code to 0 ECHO exiting in 10 seconds..........&ECHO. ECHO hit PAUSE on keyboard to pause... any key will resume exit FOR /l %%a in (10,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL) Title Press any key to exit . . .&ECHO.&EXIT /B 0 REM ------------------------------ exit now --------------------------------- :end EXIT /B 0 REM -------------------- Function Section (outside of local) ---------------- :errorfunc ECHO The exit error code is: %ERRORLEVEL%, errorlevel will be reset to 0 on exit goto :eof