Skip to content

Instantly share code, notes, and snippets.

@hartbit
Created December 11, 2013 08:57
Show Gist options
  • Save hartbit/7907108 to your computer and use it in GitHub Desktop.
Save hartbit/7907108 to your computer and use it in GitHub Desktop.
NSFileManager* fileManager = [NSFileManager new];
NSURL* directoryURL = [NSURL fileURLWithPath:@"~/photos"];
NSArray* contents = [fileManager contentsOfDirectoryAtURL:directoryURL includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:NULL];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"pathExtension == 'jpg' OR pathExtension == 'jpeg'"];
for (NSURL* fileURL in [contents filteredArrayUsingPredicate:predicate]) {
NSURL* rawFileURL = [[fileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"raw"];
if (![fileManager fileExistsAtPath:[rawFileURL path]]) {
[fileManager removeItemAtURL:fileURL error:NULL];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment