             case .File(let name):
                 print("Creating Case: \(name)")
                 let indentationString = String(count: 4 * (indentLevel + 1), repeatedValue: Character(" "))
-                if name.characters.contains(Character(" ")) {
-                    let correctedName = name.stringByReplacingOccurrencesOfString(" ", withString: "")
+                if let correctedName = correctedNameForString(name) {
                     resultString += indentationString + "case \(correctedName) = \"\(name)\"\n"
                 } else {
                     resultString += indentationString + "case \(name)\n"


struct FileBuilder {
    static func fileStringWithEnumString(enumString: String) -> String {
        return acknowledgementsString() + "\n\n" + imageExtensionString() + "\n" + enumString
    }
    
    private static func acknowledgementsString() -> String {

        case File(String)
        case Directory((String, [Resource]))
    }
    
    private static let forbiddenCharacterSet: NSCharacterSet = {
        let validSet = NSMutableCharacterSet(charactersInString: "_")
        validSet.formUnionWithCharacterSet(NSCharacterSet.letterCharacterSet())
        return validSet.invertedSet
        }()
    
    static func enumStringForPath(path: String, topLevelName: String = "Shark") throws -> String {
        let resources = try imageResourcesAtPath(path)
