windowsbatch-filecmdwindows-console

How to find and delete a file with CMD command?


I know the filename, say myfile.pdf. But I do not know its location because my web application created it temporarily. When the user disconnect from the application then I want this file to be deleted. So how to search and delete the file?


Solution

  • del path\filename /s
    

    e.g.

    del c:\test\h.bat /s
    

    Will delete h.bat in any sub folders from the test directory.

    To search and delete on an entire drive: -

    del c:\test.bat /s
    

    The S switch deletes all specified files from all subdirectories.