当前两个字符为 ZZ 时删除文件
我想在前两个字符等于 zz
或 ZZ
时删除所有文件。我该怎么做呢?
I want to delete all the files when the first two characters are equal to zz
or ZZ
. How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
从名称以“zz”开头的路径中获取所有对象(包括隐藏的、递归的),过滤掉目录对象并删除这些项目。
Get all objects (including hidden, recursively) from a path with names starting with 'zz', filter out directory objects and delete the items.
这对我有用:
This works for me:
使用-filter 速度更快。当您确定这就是您想要的时,请去掉“-whatif”。
It's faster with -filter. Take off the -whatif when you're sure it's what you want.
NSFileManager *FileManager = [NSFileManager defaultManager];
NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//Faccio la dir dei file *.txt da preparare
NSDirectoryEnumerator *DirFile = [FileManager enumeratorAtPath:[Paths objectAtIndex:0]];
IFileTxt = [[NSMutableArray alloc] init];
NSString *文件;
while ((file = [DirFile nextObject])) {
}
[IFileTxt 发布];
NSFileManager *FileManager = [NSFileManager defaultManager];
NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//Faccio la dir dei file *.txt da preparare
NSDirectoryEnumerator *DirFile = [FileManager enumeratorAtPath:[Paths objectAtIndex:0]];
IFileTxt = [[NSMutableArray alloc] init];
NSString *file;
while ((file = [DirFile nextObject])) {
}
[IFileTxt release];