BATCH Delete subfile/folder in a directory

Hello,

I would like to create a script that can delete specific subfiles and folders in multiple directories.

Do you have an example of a script or command lines, please?

Thank you!

Configuration: Windows / Firefox 50.0

3 answers

  1. Hello,

    To delete a folder and everything it contains:
    rmdir /s /q "folder to delete"


    To delete specific folders within multiple folders, you need to provide more details.

    I assume this is related to the logs of your FTP server.
    1
    1. In fact, I would like to delete specific files, for example:
      Delete all files containing "Sample" in their name.
      Several of these files exist in different folders within the directory.
      Do you have any idea?
      0


      1. @echo off

        set source="the directory of your choice"

        cd %USERPROFILE%

        for /f "tokens=*" %%A In ('dir /a-d /b /s %source%\*.* ^| find /i "Sample"') do (del /f "%%A" && echo %%~sA = deletion OK && echo.)

        pause

        This code searches for "Sample" recursively and deletes the corresponding files.

        You must replace the underlined part with the directory of your choice.
        0