首页 > 解决方案 > 使用 powershell 删除 zip 文件夹

问题描述

我在同一路径中有一个 zip 文件夹和一个普通文件夹。我只需要从该路径中删除 zip 文件夹

在此处输入图像描述

我尝试使用这个脚本:

$TestPath='D:\RAW\St\Documentum\2021-10-12\VPA_IMAGES'
Get-ChildItem -Filter *.zip | `
  ForEach-Object { if ($TestPath $_.BaseName) {
    Remove-Item -Recurse -Force $_.BaseName }
  }

它不会删除该 zip 文件夹。如何删除该 zip 文件夹?

标签: powershell

解决方案


$TestPath='E:\testing'
Get-ChildItem -Path $TestPath -Filter '*.zip' | Remove-Item
  

在此处输入图像描述


推荐阅读