private String getValidName(String name, String extension) {
        String cleanName = name;
        String[] splits = name.split("\\.");
        if (splits.length != 0) {
            if (splits[splits.length-1].equalsIgnoreCase(extension)) {
                cleanName = "";
                for(int i = 0; i < splits.length-2; i++) {
                    cleanName += splits[i] + ".";
                }
                cleanName += splits[splits.length-2];
            }
        }
        return cleanName;
    }