Last active
October 15, 2019 06:05
-
-
Save andrewwoz/0edb78ff1a17a5263e32e704947fbf5f to your computer and use it in GitHub Desktop.
[Enumerating elements in directory] #fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let resourceKeys: [URLResourceKey] = [.creationDateKey, .nameKey, .fileSizeKey] | |
let desctopEnumerator = fs.enumerator(at: desctop, includingPropertiesForKeys: resourceKeys)! | |
for case let fileURL as URL in desctopEnumerator { | |
guard let resourceProps = try? fileURL.resourceValues(forKeys: Set(resourceKeys)), | |
let size = resourceProps.fileSize, | |
let date = resourceProps.creationDate, | |
let name = resourceProps.name else { continue } | |
let sizeMB = size / 1_048_576 | |
if sizeMB > 10 { | |
print("\(name):\(date)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment