• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: File Extensions Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File Extensions Problem


  • Subject: Re: File Extensions Problem
  • From: Ingvar Nedrebo <email@hidden>
  • Date: Thu, 28 Aug 2008 16:25:44 +0100

Adil,

I use NSWorkspace and UTI types to do this, as in the code below. Look at the UTI hierarchy and replace "public.movie" in the code with whichever type covers the files you're interested in.


-(NSArray *)mediaFilesInFolder:(NSString *)folderPath { NSMutableArray * files = [NSMutableArray array]; NSWorkspace * ws = [NSWorkspace sharedWorkspace]; NSArray * paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:NULL];

for (NSString * fn in paths)
{
NSString * absPath = [folderPath stringByAppendingPathComponent:fn];
NSString * type = [ws typeOfFile:absPath error:nil];


        if ([ws type:type conformsToType:@"public.movie"])
        {
            [files addObject:absPath];
        }
    }
    return files;
}



Ingvar


On Aug 22, 2008, at 07:29, Adil Saleem wrote:

Hi,

I want to display in a tableview, list of all media files (audio, video files) present in a certain directory.

Currently what i am doing is that i am getting the file names in an NSMutableArray using NSFileManager function directoryContentsAtPath

I get the list, but the problem is that it get all the files. I want only those files that have a certain extension (for example mp4, mp3). How can i do that.

Thanx in advance

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >File Extensions Problem (From: Adil Saleem <email@hidden>)

  • Prev by Date: Re: CFBundleIconFile: heiß or hot?
  • Next by Date: Re: Semi-transparent offscreen CALayer
  • Previous by thread: Re: File Extensions Problem
  • Next by thread: Re: File Extensions Problem
  • Index(es):
    • Date
    • Thread