1. Get a list of all the files which have the same name pattern. This will give you a chance to verify what is deleted before actually deleting them. To do so, type: dir filename.ext /a /b /s (where filename.extis the name of the files which you’d like to find; wildcards are also acceptable.)
    For example:
    dir file.txt /a /b /s
  2. List all files with same name into a file.
    dir thumbs.db /a /b /s >> filelist.txt
  3. Delete those files. Type del filename.ext /a /s (where filename.extis the name of the files which you’d like to delete; wildcards are also acceptable.)
    For example:
    del file.txt /a /s

3 thoughts on “Windows Command to list and delete specific files from subfolders

  1. $backupFile”;
    // echo $command . “\n”;
    // system($command, $result);
    $result = exec($command);
    echo $result . “\n\n”;

    $command = ‘mysqldump’ . ” -u$username -p’$password’ -h$hostname $database $ignoretables >> $backupFile”;
    // echo $command . “\n”;
    // system($command, $result);
    $result = exec($command);
    echo $result . “\n\n”;
    }

    function zipFile($backupFile, $zipFile) {
    echo “zipping…\n”;
    chdir(‘dumps’);

    $command = “zip $zipFile $backupFile”;
    echo $command . “\n”;
    // system($command, $result);
    $result = exec($command);
    echo $result . “\n”;

    unlink($backupFile);
    }

    @mkdir(‘dumps’);
    $fname = date(“Y-m-d-H-i-s”) . ‘.sql’;
    $zipFile = date(“Y-m-d-H-i-s”) . ‘.zip’;
    $backupFile = ‘dumps/’ . $fname;

    //$ignore = ‘aga_localstores’;
    //$ignore = $argv[1];
    echo “Ignoring = $ignore\n”;
    makeDump($backupFile, explode(‘,’, $ignore));
    zipFile($fname, $zipFile);
    echo “Finished”;

Leave a Reply

Your email address will not be published. Required fields are marked *