我试图从Azure存储文件共享中删除所有文件,并排除一个特定的文件名。我就是搞不懂这个模式。
我试过了,但现在的模式不匹配了。
az storage file delete-batch --source "https://myst.file.core.windows.net/myshare" --sas-token $sastoken --pattern "[!importantfile.py]"发布于 2021-08-31 08:01:57
您需要在单引号中添加模式参数,如下所示
az storage file delete-batch --source "https://myst.file.core.windows.net/myshare" --sas-token $sastoken --pattern '[!importantfile.py]*' 如果文件共享中有类似的文件,如(test.json.test1.json),则使用
az存储删除-带模式筛选器的批处理不可能排除特定文件的删除。
线程如何在az storage blob delete-batch中使用模式
或者,如果希望从文件共享中删除特定文件,则可以使用下面的power shell脚本
connect-azaccount
$accountName = '<accountname>';
$accountKey = '<accountkey>';
$myshare = '<file sharename >';
$notremovalfile = '<file that need to be excluded from deletion>';
$filelist = az storage file list -s $myshare --account-name $accountName --account-key $accountKey
$fileArray = $filelist|ConvertFrom-Json
foreach ($file in $fileArray)
{
if($file.name -ne $notremovalfile)
{
Write-Host $file.name
az storage file delete --account-name $accountName --account-key $accountKey -s $myshare -p $file.name
Write-Host "deleting $file.name"
}
} https://stackoverflow.com/questions/68980623
复制相似问题