You need to roll your own method to eliminate the files you don't want.
This isn't easy with the built in tools, but you could use RegExKit Lite to assist with finding the elements in the returned array you are interested in. According to the release notes this should work in both Cocoa and Cocoa-Touch applications.
Here's the demo code I wrote up in about 10 minutes. I changed the < and > to " because they weren't showing up inside the pre block, but it still works with the quotes. Maybe somebody who knows more about formatting code here on StackOverflow will correct this (Chris?).
This is a "Foundation Tool" Command Line Utility template project. If I get my git daemon up and running on my home server I'll edit this post to add the URL for the project.
#import "Foundation/Foundation.h" #import "RegexKit/RegexKit.h" @interface MTFileMatcher : NSObject { } - (void)getFilesMatchingRegEx:(NSString*)inRegex forPath:(NSString*)inPath; @end int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; // insert code here... MTFileMatcher* matcher = [[[MTFileMatcher alloc] init] autorelease]; [matcher getFilesMatchingRegEx:@"^.+\\.[Jj][Pp][Ee]?[Gg]$" forPath:[@"~/Pictures" stringByExpandingTildeInPath]]; [pool drain]; return 0; } @implementation MTFileMatcher - (void)getFilesMatchingRegEx:(NSString*)inRegex forPath:(NSString*)inPath; { NSArray* filesAtPath = [[[NSFileManager defaultManager] directoryContentsAtPath:inPath] arrayByMatchingObjectsWithRegex:inRegex]; NSEnumerator* itr = [filesAtPath objectEnumerator]; NSString* obj; while (obj = [itr nextObject]) { NSLog(obj); } } @end