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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to