在PowerShell中强制删除目录及其所有子目录的最简单方法是什么?我在Windows 7中使用PowerShell V2。
我从几个消息来源了解到,最明显的命令Remove-Item $targetDir -Recurse -Force
无效。这包括PowerShell V2在线帮助(使用Get-Help Remove-Item -Examples
找到)中的声明:
...由于此cmdlet中的Recurse参数有问题,因此该命令使用Get-Childitem cmdlet获取所需的文件,并使用管道运算符将它们传递给Remove-Item cmdlet ...
我见过各种使用 Get-ChildItem 并将其传递给 Remove-Item 的示例,但这些示例通常会根据过滤器删除一些文件,而不是整个目录。
我正在寻找最简洁的方法来吹灭整个目录,文件和子目录,而不使用最少量的代码生成任何用户警告消息。如果容易理解的话,单行会很好。
答案 0 :(得分:411)
Remove-Item -Recurse -Force some_dir
确实像在这里宣传的那样有效。
rm -r -fo some_dir
也是有效的速记别名。
据我所知,当您尝试递归删除过滤的文件集时,-Recurse
参数无法正常工作。为了杀死一个单一的目录和下面的一切似乎工作正常。
答案 1 :(得分:36)
我用过:
rm -r folderToDelete
这对我来说就像一个魅力(我从Ubuntu偷了它)。
答案 2 :(得分:20)
使用简单Remove-Item "folder" -Recurse
递归删除文件时,我有时会看到间歇性错误:[folder] cannot be removed because it is not empty.
此答案会尝试通过单独删除文件来防止出现此错误。
function Get-Tree($Path,$Include='*') {
@(Get-Item $Path -Include $Include -Force) +
(Get-ChildItem $Path -Recurse -Include $Include -Force) |
sort pspath -Descending -unique
}
function Remove-Tree($Path,$Include='*') {
Get-Tree $Path $Include | Remove-Item -force -recurse
}
Remove-Tree some_dir
一个重要的细节是使用pspath -Descending
对所有项目进行排序,以便在根之前删除叶子。排序是在pspath
参数上完成的,因为它有更多机会为文件系统以外的提供程序工作。如果您要过滤要删除的项目,-Include
参数只是一种便利。
它分为两个函数,因为我发现通过运行
来查看我要删除的内容很有用Get-Tree some_dir | select fullname
答案 3 :(得分:10)
试试这个例子。如果该目录不存在,则不会引发错误。您可能需要PowerShell v3.0。
remove-item -path "c:\Test Temp\Test Folder" -Force -Recurse -ErrorAction SilentlyContinue
答案 4 :(得分:9)
rm -r ./folder -Force
......为我工作
答案 5 :(得分:8)
使用旧式DOS命令:
rd /s <dir>
答案 6 :(得分:6)
要避免&#34;目录不为空&#34;接受的答案的错误,只需使用之前建议的旧的旧DOS命令。准备好复制粘贴的完整PS语法是:
& cmd.exe /c rd /S /Q $folderToDelete
答案 7 :(得分:5)
出于某种原因John Rees&#39;答案有时在我的情况下不起作用。但它使我朝着以下方向前进。 首先,我尝试使用buggy -recurse选项以递归方式删除目录。然后我进入左边的每个子目录并删除所有文件。
function Remove-Tree($Path)
{
Remove-Item $Path -force -Recurse -ErrorAction silentlycontinue
if (Test-Path "$Path\" -ErrorAction silentlycontinue)
{
$folders = Get-ChildItem -Path $Path –Directory -Force
ForEach ($folder in $folders)
{
Remove-Tree $folder.FullName
}
$files = Get-ChildItem -Path $Path -File -Force
ForEach ($file in $files)
{
Remove-Item $file.FullName -force
}
if (Test-Path "$Path\" -ErrorAction silentlycontinue)
{
Remove-Item $Path -force
}
}
}
答案 8 :(得分:2)
我采取了另一种灵感来自@ john-rees的方法 - 尤其是当他的方法在某些时候开始失败时。基本上递归子树并按路径长度排序文件 - 从最长到最短删除
Get-ChildItem $tfsLocalPath -Recurse | #Find all children
Select-Object FullName,@{Name='PathLength';Expression={($_.FullName.Length)}} | #Calculate the length of their path
Sort-Object PathLength -Descending | #sort by path length descending
%{ Get-Item -LiteralPath $_.FullName } |
Remove-Item -Force
关于-LiteralPath魔法,这是另一个可能会打你的问题:https://superuser.com/q/212808
答案 9 :(得分:1)
另一个有用的技巧:
如果您发现很多具有相同或相似名称约定的文件(例如带有点前缀名称的mac文件......那个着名的文件提取),您可以使用powershell中的一行轻松删除它们,如下所示:
ls -r .* | rm
此行将删除当前目录中名称开头的所有带有点的文件,以及此目录中其他文件夹内具有相同情况的所有文件。使用它时要注意它。 :d
答案 10 :(得分:1)
del <dir> -Recurse -Force # I prefer this, short & sweet
OR
remove-item <dir> -Recurse -Force
如果目录很大,那么我通常要做的是
while (dir | where name -match <dir>) {write-host deleting; sleep -s 3}
在另一个powershell终端上运行它,完成后它将停止。
答案 11 :(得分:1)
要删除包括文件夹结构在内的完整内容,请使用
get-childitem $dest -recurse | foreach ($_) {remove-item $_.fullname -recurse}
添加到-recurse
的{{1}}可确保禁用交互式提示。
答案 12 :(得分:1)
删除整个文件夹树有时会有效,有时会因“目录不为空”错误而失败。随后尝试检查文件夹是否仍然存在可能导致“拒绝访问”或“未授权访问”错误。我不知道为什么会发生这种情况,尽管可以从this StackOverflow posting获得一些见解。
通过指定删除文件夹中项目的顺序以及添加延迟,我能够解决这些问题。以下内容对我来说运行良好:
# First remove any files in the folder tree
Get-ChildItem -LiteralPath $FolderToDelete -Recurse -Force | Where-Object { -not ($_.psiscontainer) } | Remove-Item –Force
# Then remove any sub-folders (deepest ones first). The -Recurse switch may be needed despite the deepest items being deleted first.
ForEach ($Subfolder in Get-ChildItem -LiteralPath $FolderToDelete -Recurse -Force | Select-Object FullName, @{Name="Depth";Expression={($_.FullName -split "\\").Count}} | Sort-Object -Property @{Expression="Depth";Descending=$true}) { Remove-Item -LiteralPath $Subfolder.FullName -Recurse -Force }
# Then remove the folder itself. The -Recurse switch is sometimes needed despite the previous statements.
Remove-Item -LiteralPath $FolderToDelete -Recurse -Force
# Finally, give Windows some time to finish deleting the folder (try not to hurl)
Start-Sleep -Seconds 4
PowerShell中的Microsoft TechNet文章Using Calculated Properties对于获取按深度排序的子文件夹列表非常有帮助。
RD / S / Q 的类似可靠性问题可以通过两次运行 RD / S / Q 来解决 - 理想情况下在两者之间暂停(即使用 ping ,如下所示。)
RD /S /Q "C:\Some\Folder\to\Delete" > nul
if exist "C:\Some\Folder\to\Delete" ping -4 -n 4 127.0.0.1 > nul
if exist "C:\Some\Folder\to\Delete" RD /S /Q "C:\Some\Folder\to\Delete" > nul
答案 13 :(得分:1)
非常简单:
remove-item -path <type in file or directory name>, press Enter
答案 14 :(得分:0)
由于基础文件系统是异步的,因此在Windows上似乎library(dplyr)
dat %>%
group_by(y) %>%
summarize(across(v1:v3, mean))
可能会间歇性失败。 This answer似乎可以解决。用户还一直积极参与Powershell团队on GitHub。
答案 15 :(得分:0)
如果您致力于使用powershell,则可以使用它,如公认的答案所述:
rm -r -fo targetDir
但是我发现使用Windows命令提示符会更快
rmdir /s/q targetDir
除了更快之外,使用命令提示符选项的另一个优点是它可以立即开始删除文件(powershell首先进行枚举),因此,如果在运行时出现问题,则至少在删除方面取得了一些进展文件。
答案 16 :(得分:0)
基于 @John Rees 的 answer 进行了一些改进。
初始文件 tree . /f
C:\USERS\MEGAM\ONEDRIVE\ESCRITORIO\PWSHCFX
│ X-Update-PowerShellCoreFxs.ps1
│ z
│ Z-Config.json
│ Z-CoreFxs.ps1
│
├───HappyBirthday Unicorn
│ collection-of-unicorns-and-hearts-with-rainbows.zip
│ hand-drawing-rainbow-design.zip
│ hand-drawn-unicorn-birthday-invitation-template (2).zip
│ hontana.zip
│ Unicorn - Original.pdf
│ Unicorn-free-printable-cake-toppers.png
│ Unicorn.pdf
│ Unicorn.png
│ Unicorn2.pdf
│ Unicorn3.pdf
│ Unicorn4.pdf
│ Unicorn5.pdf
│ UnicornMLP.pdf
│
├───x
└───y
代码
function Get-ItemTree() {
param (
[Parameter()]
[System.String]
$Path = ".",
[Parameter()]
[System.String]
$Include = "*",
[Parameter()]
[switch]
$IncludePath,
[Parameter()]
[switch]
$Force
)
$result = @()
if (!(Test-Path $Path)) {
throw "Invalid path. The path `"$Path`" doesn't exist." #Test if path is valid.
}
if (Test-Path $Path -PathType Container)
{
$result += (Get-ChildItem "$Path" -Include "$Include" -Force:$Force -Recurse) # Add all items inside of a container, if path is a container.
}
if($IncludePath.IsPresent)
{
$result += @(Get-Item $Path -Force) # Add the $Path in the result.
}
$result = ,@($result | Sort-Object -Descending -Unique -Property "PSPath") # Sort elements by PSPath property, order in descending, remove duplicates with unique.
return $result
}
function Remove-ItemTree {
param (
[Parameter()]
[System.String]
$Path,
[Parameter()]
[switch]
$ForceDebug
)
(Get-ItemTree -Path $Path -Force -IncludePath) | ForEach-Object{
Remove-Item "$($_.PSPath)" -Force
if($PSBoundParameters.Debug.IsPresent)
{
Write-Debug -Message "Deleted: $($_.PSPath)" -Debug:$ForceDebug
}
}
}
Write-Host "███ Test 1"
$a = Get-ItemTree "./Z-Config.json" -Force -Include "*" -IncludePath:$true # Tree of a file path. 1 element the file (IncludePath parameter = $true)
$a | Select-Object -ExpandProperty PSPath | ConvertTo-Json
Write-Host
Write-Host "███ Test 2"
$b = Get-ItemTree "./Z-Config.json" -Force -Include "*" -IncludePath:$false # Tree of a file path. No Result (IncludePath parameter = $false)
$b | Select-Object -ExpandProperty PSPath | ConvertTo-Json
Write-Host
Write-Host "███ Test 3"
$c = Get-ItemTree "." -Force -Include "*" -IncludePath:$true # Tree of a container path. All elements of tree and the container included (IncludePath parameter = $true).
$c | Select-Object -ExpandProperty PSPath | ConvertTo-Json
Write-Host
Write-Host "███ Test 4"
$d = Get-ItemTree "." -Force -Include "*" -IncludePath:$false # All elements of tree, except the container (IncludePath parameter = $false).
$d | Select-Object -ExpandProperty PSPath | ConvertTo-Json
Write-Host
Remove-ItemTree -Path "./HappyBirthday Unicorn" -Debug -ForceDebug #Remove the contents of container and remove the container. -Debug Prints debug messages and -ForceDebug forces to prints messages if DebugPreference is SilentlyContinue.
Remove-ItemTree -Path "./x" -Debug -ForceDebug #Remove the contents of container and remove the container. -Debug Prints debug messages and -ForceDebug forces to prints messages if DebugPreference is SilentlyContinue.
Remove-ItemTree -Path "./y" -Debug -ForceDebug #Remove the contents of container and remove the container. -Debug Prints debug messages and -ForceDebug forces to prints messages if DebugPreference is SilentlyContinue.
Remove-ItemTree -Path "./z" -Debug -ForceDebug #Remove file. -Debug Prints debug messages and -ForceDebug forces to prints messages if DebugPreference is SilentlyContinue.
Get-ChildItem -Force
输出
███ Test 1
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\Z-Config.json"
███ Test 2
███ Test 3
[
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\Z-CoreFxs.ps1",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\Z-Config.json",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\z",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\y",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\X-Update-PowerShellCoreFxs.ps1",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\x",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\UnicornMLP.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn5.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn4.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn3.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn2.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn.png",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn-free-printable-cake-toppers.png",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn - Original.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hontana.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hand-drawn-unicorn-birthday-invitation-template (2).zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hand-drawing-rainbow-design.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\collection-of-unicorns-and-hearts-with-rainbows.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx"
]
███ Test 4
[
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\Z-CoreFxs.ps1",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\Z-Config.json",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\z",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\y",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\X-Update-PowerShellCoreFxs.ps1",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\x",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\UnicornMLP.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn5.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn4.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn3.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn2.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn.png",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn-free-printable-cake-toppers.png",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\Unicorn - Original.pdf",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hontana.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hand-drawn-unicorn-birthday-invitation-template (2).zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\hand-drawing-rainbow-design.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn\\collection-of-unicorns-and-hearts-with-rainbows.zip",
"Microsoft.PowerShell.Core\\FileSystem::C:\\Users\\Megam\\OneDrive\\Escritorio\\pwshcfx\\HappyBirthday Unicorn"
]
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\UnicornMLP.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn5.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn4.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn3.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn2.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn.png
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn-free-printable-cake-toppers.png
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\Unicorn - Original.pdf
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\hontana.zip
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\hand-drawn-unicorn-birthday-invitation-template (2).zip
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\hand-drawing-rainbow-design.zip
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn\collection-of-unicorns-and-hearts-with-rainbows.zip
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\HappyBirthday Unicorn
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\x
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\y
DEBUG: Deleted: Microsoft.PowerShell.Core\FileSystem::C:\Users\Megam\OneDrive\Escritorio\pwshcfx\z
Directory: C:\Users\Megam\OneDrive\Escritorio\pwshcfx
Mode LastWriteTime Length Name
---- ------------- ------ ----
la--- 17/5/2021 1:57 272 X-Update-PowerShellCoreFxs.ps1
la--- 14/5/2021 18:51 252 Z-Config.json
la--- 17/5/2021 4:04 30931 Z-CoreFxs.ps1
树。 /f
C:\USERS\MEGAM\ONEDRIVE\ESCRITORIO\PWSHCFX
X-Update-PowerShellCoreFxs.ps1
Z-Config.json
Z-CoreFxs.ps1
No subfolders exist
答案 17 :(得分:-1)
$users = get-childitem \\ServerName\c$\users\ | select -ExpandProperty name
foreach ($user in $users)
{
remove-item -path "\\Servername\c$\Users\$user\AppData\Local\Microsoft\Office365\PowerShell\*" -Force -Recurse
Write-Warning "$user Cleaned"
}
写上面的内容来清理一些日志文件而不删除父目录,这很有效!
答案 18 :(得分:-1)
rm -r <folder_name>
c:\>rm -r "my photos"