REPOST
Hapus “echo” dari |echo del “%%f” /f| untuk menfungsikan perintah hapus file.
:: --- BATCH SCRIPT START --- :bof @echo off & setlocal enableextensions enabledelayedexpansion :init :: proses nama file yang diinput if "%1"=="" ( echo Masukkan nama file dengan benar. goto :eof ) else ( set file=%* set ffile=!file:=! set file=!ffile::=! if not "!file!"=="%*" ( echo masukkan hanya nama file saja .... goto :eof ) ) :: merekam drive yang terdapat pada komputer set drives= if exist "C:Drives.txt" del "C:Drives.txt" for /f "usebackq tokens=1*" %%a in (`fsutil fsinfo drives ^| find ":"`) do ( if /i "%%a" NEQ "Drives:" ( set "drives=!drives! %%a" echo:%%a >> C:Drives.txt ) ELSE ( set "drives=!drives! %%b" echo:%%b >> C:Drives.txt ) ) for /f "tokens=*" %%d in ('type "C:Drives.txt"') do ( fsutil fsinfo drivetype %%d | find /i "Fixed" >nul if not errorlevel 1 ( echo mencari "%file%" di drive "%%d" ... call :SEARCHIT %%d ) ) :: mencari dan menghapus file jika ada :SEARCHIT pushd %* for /f "tokens=*" %%f in ('dir "%file%" /b /s /a-d 2^>nul') do ( echo del "%%f" /f if not errorlevel 1 ( echo "%%f" dihapus ) else ( echo file "%%f" tidak bisa dihapus ) ) goto :eof :eof :: --- BATCH SCRIPT END ---
simpan script tersebut, misal: dengan nama hapus.bat, kemudian gunakan dengan cara mengetik nama file script tersebut dan jenis file yang akan dihapus, misal: hapus.bat *.mpeg
source: computing.net