title: Copy wildcard filenames from main bundle to Documents?
body: <p>I can copy files from my main bundle to my Documents directory by filename with the code below, but how can I copy based on wildcard?  For example I have several files named myimageX.jpg (x representing a random number).  I would like to loop through all of them that are contained in my main bundle and if they don't exist in Documents, copy them.</p>
  
  <pre><code>BOOL success;
  NSFileManager *fileManager = [NSFileManager defaultManager];
  
  myfileName = @"myimage322.jpg";
  documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
  documentsDir = [documentPaths objectAtIndex:0];
  filePath = [documentsDir stringByAppendingPathComponent:myfileName];
  
  success = [fileManager fileExistsAtPath:filePath];
  if(success) return;
  NSString *filePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:myfileName];
  [fileManager copyItemAtPath:filePathFromApp toPath:filePath error:nil];
  
  [fileManager release];
  </code></pre>