SDE
SDE

Reputation: 31

Azcopy remove file in a directory but not the parent directory

I want to remove the files inside a directory but azcopy rm command removes the parent directory as well.

For example, I want to remove all the files inside:

https://[account].blob.core.windows.net/[container]/test_folder1/test_folder2/

But when I run the following command, the test_folder2 gets deleted as well.

azcopy rm "https://[account].blob.core.windows.net/[container]/test_folder1/test_folder2/*?[SAS]" --recursive=true

And I am left with:

https://[account].blob.core.windows.net/[container]/test_folder1/

I don't want to delete the test_folder2. Only the files inside it.

--recursive=false doesn't seem to work as well. It throws the following error:

Description=409 The recursive query parameter value must be true to delete a non-empty directory.

I am using Azcopy version 10.10.0. Tried looking up for the solution but honestly can't tell if it is expected behavior or something is wrong on my side. Any help would be appreciated.

Upvotes: 0

Views: 2974

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 89361

In Azure blob storage accounts without Hierarchical Namespace there are no real folders.

For

https://[account].blob.core.windows.net/[container]/test_folder1/test_folder2/foo.bar

The blob's name is

/test_folder1/test_folder2/foo.bar

If you delete all the blobs that have /test_folder2/ as part of their name, then there no longer appears to be such a folder. But it never really existed in the first place.

Upvotes: 1

Related Questions