NSFileManager *mgr = [NSFileManagerdefaultManager];
NSString *dir =@"/Users/apple/Desktop/videos";
NSArray *subpaths = [mgr subpathsAtPath:dir];
for (NSString *subpathin subpaths) {
if (![subpath hasSuffix:@"mp4"]) continue;
// 获得全路径
NSString *fullSubpath = [dir stringByAppendingPathComponent:subpath];
// 获得文件名(删除扩展名. MP4)
NSString *filename = [subpath.lastPathComponentstringByDeletingPathExtension];
// 根据文件名获取对应的前缀和后缀
NSString *prefix = [filename stringByMatching:@"(\\d{6})_.清"capture:YES];
NSString *suffix = [filename stringByMatching:@"(.+) \\d{6}_.清"capture:YES];
NSString *newFilename = [NSStringstringWithFormat:@"%@-%@", prefix, suffix];
// 生成新的全路径
NSString *newFullSubpath = [fullSubpathstringByReplacingOccurrencesOfString:filename withString:newFilename];
// NSData *data = [NSData dataWithContentsOfFile:fullSubpath];
// [data writeToFile:newFullSubpath atomically:YES];
// [mgr removeItemAtPath:fullSubpath error:nil];
// 剪切\移动(就是用原来的文件路径替换新的文件路径)
[mgr moveItemAtPath:fullSubpath toPath:newFullSubpath error:nil];
}