简体   繁体   English

PowerShell:如何删除名称以点开头(例如“ .svn”)的文件夹

[英]PowerShell: How do you delete a folder with a name that starts with a dot (e.g. “.svn”)

Tried this: 试过这个:

Remove-Item "C:\foo\.svn"

but this is the error that I encountered 但这是我遇到的错误

Remove-Item : Cannot find path 'C:\foo\.svn' because it does no
t exist.
At line:1 char:12
+ Remove-Item <<<<  "C:\foo\.svn"
    + CategoryInfo          : ObjectNotFound: (C:\foo\.svn:String) [Remove-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Hmm, this works for me. 嗯,这对我有用。 Are you sure the directory exists? 您确定目录存在吗? Perhaps it is hidden. 也许它是隐藏的。 If so try: 如果是这样,请尝试:

Remove-Item C:\foo\.svn -force -recurse

我确定其中一位大师的方法更简洁,但这应该可行:

gci | where {$_.name -match '.svn'} | remove-item
 rm .test 

为我工作,这里没有问题。

可能是由于权限不正确,尝试的一件事是添加-Force标志:

Remove-Item "C:\foo\.svn" -Force

Try this: 尝试这个:

Remove-Item C:\foo\.svn

or this: 或这个:

Remove-Item C:\foo\\.svn

Worked for me. 为我工作。

Make sure the file actually exists and doesn't have a extension you're not providing. 确保文件确实存在,并且没有您没有提供的扩展名。 Try listing the contents of the directory to it isn't the directory not found and that it actually contains the files you think it does. 尝试将目录的内容列出到找不到目录的位置,并且目录实际上包含您认为的目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从PowerShell“捆绑”一个文件夹(例如,创建一个未压缩的zip) - “Bundle” a folder (e.g. Create an uncompressed zip) from PowerShell 如何在Powershell中定义不带任何值的可选参数? (例如,get-object -verbose) - How do I define an optional parameter in powershell that takes no value? (e.g. get-object -verbose) 如何为 PowerShell 设置默认文本编辑器(例如 Visual Studio Code) - How to set a default text editor for PowerShell (e.g. Visual Studio Code) 如何在Powershell中获取复选框的实时状态,例如checkboxesVM.checked? - How can I obtain the live state of the checkbox e.g. checkboxesVM.checked in powershell? 如果脚本在后台(例如 Windows 任务计划程序)或用户会话中运行,如何检查 PowerShell - How to check in PowerShell if the script was run in background (e.g. Windows Task Scheduler) or in user session Bicep - 如何初始化 PowerShell Azure Function 的应用程序文件(例如 requirements.psd1)? - Bicep - How to initialize app files of PowerShell Azure Function (e.g. requirements.psd1)? 在Windows PowerShell中有条件地执行进程(例如Bash中的&amp;&amp;和||运算符) - Execute process conditionally in Windows PowerShell (e.g. the && and || operators in Bash) 如何在 powershell 中删除用户配置文件? - How do you delete user profiles in powershell? 在Powershell中,如何将文件夹目录的格式设置为单词或句子,而不是整个目录名? - In Powershell, how do you format a folder directory to be a word or sentence rather than the whole directory name? 如何使用PowerShell从Excel中的命名区域返回单元格区域(例如A10:C20) - How to return a cell range (e.g. A10:C20) from a named range in Excel using PowerShell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM