gpt4 book ai didi

Azure CLI : storage blob delete-batch to delete all blobs excluding two directories

转载 作者:行者123 更新时间:2023-12-03 13:54:05 24 4
gpt4 key购买 nike

我有一个 PowerShell 脚本,当前可以删除 $web 容器中的所有 Blob。

az storage blob delete-batch --account-name myaccountname --source $web

这很好用,但现在我想排除两个目录被删除。我看过the documentation而且我仍然不确定排除语法应该是什么样子。

我确信我必须使用 --pattern 参数。

The pattern used for globbing files or blobs in the source. The supported patterns are '*', '?', '[seq]', and '[!seq]'.

我希望有人能让我知道 --pattern 参数的值应该是什么样子,以便我可以删除 $web 容器中除 中的 blob 之外的所有内容/aaa/bbb 目录。

az storage blob delete-batch --account-name myaccountname --source $web --pattern ???

最佳答案

根据我的测试,如果你想通过参数--pattern来排除某个目录被删除,可以使用表达式'[[!]]'

az storage blob delete-batch --source <container_name> --account-name <storage_account_name> --pattern '[!<folder name>]*'

例如:

  1. 在运行命令之前,我的容器的结构如下所示。

enter image description here

  • 运行命令
  •     az storage blob delete-batch --source test --account-name blobstorage0516 --pattern '[!user&&!people]*'
  • 运行命令后,容器的结构如下所示。

    enter image description here

  • 关于Azure CLI : storage blob delete-batch to delete all blobs excluding two directories,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57713726/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com