我想从一堆文本文件中删除内容。
在每个文本文件中-在******之后删除所有内容
$Path = "C:\Users\Desktop\Delete\*.txt" # Folder Containing Text files
$OutPath = "C:\Users\Desktop\Files\"
Get-Content c.txt | Where { $_ -notmatch "*****" } | Set-Content $OutPath
我已经看到此powershell删除文件中每一行的字符后的所有内容
我无法正常工作
我是电源外壳的新手,请原谅我的代码。
谢谢
您可以使用的-Delimiter
参数Get-Content
轻松完成此操作:
免责声明:未经测试
$Path = "C:\Users\Desktop\Delete\*.txt" # Folder Containing Text files
$OutPath = "C:\Users\Desktop\Files\"
Foreach ($file in (Get-Childitem $path))
{
(Get-Content $file.fullname -Delimiter '*****')[0] |
Set-Content "$OutPath\$($file.name)"
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句