let files = try fm.contentsOfDirectory(at: dir, includingPropertiesForKeys: nil) .filter { (file) in var isDir = false return fm.fileExists(at: file, isDirectory: &isDir) && !isDir }.map { $0.lastPathComponent }