How do you delete all the contents of a directory without deleting the directory itself? I want to basically empty a folder yet leave it (and the permissions) intact.
Swift 3 if anyone needs it for a quick cut/paste
let fileManager = FileManager.default let fileUrls = fileManager.enumerator(at: folderUrl, includingPropertiesForKeys: nil) while let fileUrl = fileUrls?.nextObject() { do { try fileManager.removeItem(at: fileUrl as! URL) } catch { print(error) } }