Question

If I have a file named " mic.txt" on a Hard drive, What are the codes that find this file and delete it ??

If batch files can't do this, What are there any other ways ?

Was it helpful?

Solution

delete_my_file.bat

@echo off
set file_to_delete=mic.txt
set dir_to_look_in=C:\

:: Starting loop
for /f "tokens=1* delims=" %%f in ('dir /s /o /b "%dir_to_look_in%" ^| findstr "%file_to_delete%"') do (
    echo INFO: Deleting: %%f
    del /q "%%f"
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top