搜索文件内重名的文件(OC)
自定义要查找的重名文件的后缀,并做筛选
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *fileList = [[NSArray alloc] init];
//fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组
fileList = [fileManager subpathsOfDirectoryAtPath:@"/Users/hb/Desktop/Teld Ver3.0.0/Teld/imageResource" error:&error];
for (int i = 0; i < fileList.count; i ++) {
NSString *str1 = fileList[i];
if ([str1 containsString:@"/"]) {
NSString *temp1 = [str1 componentsSeparatedByString:@"/"].lastObject;
if ([temp1 containsString:@".png"] && ![str1 containsString:@"AMap.bundle/"]) {
for (int j = i+1; j < fileList.count; j ++) {
NSString *str2 = fileList[j];
NSString *temp2 = [str2 componentsSeparatedByString:@"/"].lastObject;
if ([temp1 isEqualToString:temp2]) {
NSLog(@"%@",temp1);
}}}}}