I´m using this piece of code to get the files contained in folder pathTo_Folder.
What I get is something like this:
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-2.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-3.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Tech-4.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-1.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-2.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-3.jpg”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-4.png”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-5.png”,
“file://localhost/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen/Terra-6.jpg”
I wonder if there is a way to get only the filename without the containing folder like “Tech-2.jpg”
NSString *pathTo_Folder = @"/Users/ronny/DEV/0200-ObjC4/ModernTimes/DrawingFun/linen";
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *theFiles = [fileManager contentsOfDirectoryAtURL:
[NSURL fileURLWithPath:pathTo_Folder]
includingPropertiesForKeys:[NSArray arrayWithObject:NSURLNameKey]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
Greetings from Switzerland, Ronald Hofmann
As per the comments, if you just want the filenames: