我想要删除所有以zz
或ZZ
开头的文件。请问应该如何操作?
我想要删除所有以zz
或ZZ
开头的文件。请问应该如何操作?
获取路径中以“zz”开头的所有对象(包括隐藏的和递归的),过滤掉目录对象并删除这些项目。
Get-ChildItem <path> -Recurse -Force -Filter zz* | Where-Object {!$_.PSIsContainer} | Remove-Item
Get-ChildItem <path> -Recurse -File -Force -Filter zz* | Remove-Item
- robRemove-Item zz*
Remove-Item *.js
来删除扩展名为 .js
的文件,太棒了! - crisleo94get-childitem zz* |
where-object {$_ -cmatch "^(zz|ZZ)"} |
foreach-item {remove-item $_.fullname}
使用-filter会更快。当你确定它是你想要的时候,去掉-whatif。
get-childitem -recurse -file -filter zz* | remove-item -whatIf
NSFileManager *FileManager = [NSFileManager defaultManager]; NSArray *Paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// 创建用于准备的 txt 文件夹 NSDirectoryEnumerator *DirFile = [FileManager enumeratorAtPath:[Paths objectAtIndex:0]];
IFileTxt = [[NSMutableArray alloc] init]; NSString *file; while ((file = [DirFile nextObject])) {
//In your case you need to test substring = "ZZ"
if ([[file pathExtension] isEqualToString: @"txt"]){
[FileManager removeItemAtPath:[NSString stringWithFormat:@"%@/%@",[Paths objectAtIndex:0],file] error:nil];
}
}
[IFileTxt release];