001package org.hl7.fhir.utilities;
002
003import java.io.File;
004import java.io.FileNotFoundException;
005import java.io.IOException;
006
007public class BulkDelete {
008
009
010  private static final String DIR2 = "C:\\work\\org.hl7.fhir\\build\\vscache";
011  private static final String DIR1 = "C:\\work\\org.hl7.fhir\\build\\vscache\\validation.cache";
012  private static final String PATTERN1 = "hl7.org/fhir";
013  private static final String PATTERN2 = "OperationOutcome";
014
015  public static void main(String[] args) throws FileNotFoundException, IOException {
016//    exec(DIR1, PATTERN1);
017//    exec(DIR2, PATTERN1);
018    exec(DIR1, PATTERN2);
019    exec(DIR2, PATTERN2);
020  }
021
022  public static void exec(String d, String pattern) throws FileNotFoundException, IOException {
023    for (File f : new File(d).listFiles()) {
024      if (!f.isDirectory()) {
025        String s = TextFile.fileToString(f);
026        if (s.contains(pattern)) {
027          System.out.println("delete "+f.getAbsolutePath());
028          f.delete();
029        }
030      }
031
032    }
033  }
034
035}