【发布时间】:2016-12-24 17:40:50
【问题描述】:
c:\users\sam\desktop\test Del x1.txt x2.txt x3.txt
这工作正常。但是如何在不转到文件夹路径的情况下做到这一点。
【问题讨论】:
标签: windows shell command command-prompt
c:\users\sam\desktop\test Del x1.txt x2.txt x3.txt
这工作正常。但是如何在不转到文件夹路径的情况下做到这一点。
【问题讨论】:
标签: windows shell command command-prompt
你在这里有点深奥......编写脚本会更容易。
这是一个基本脚本,您可以从这里扩展:
#Get the path
$path = "$env:USERPROFILE\Desktop"
#Get the files in the path
$Files = Get-ChildItem $path
#Loop through each file
foreach($file in $files)
{
#Check to see if it's a text file
if($file -like "*.txt")
{
#Delete the file and do not confirm
Remove-Item $file -Confirm:$false -ErrorAction SilentlyContinue
}
}
【讨论】: