storage blob download-batch fails with "[Errno 20] Not a directory"
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### Describe the bug
The `download-batch` command fails when downloaded nested subfolders from Data Lake Storage. Folders, in this case, are represented as zero-byte blobs. For example,
```sh
az storage blob download-batch -s https://sciencelibrarieswestus2.blob.core.windows.net/external-data-share -d stanford --pattern stanford/*
```
When you download nested subfolders, a zero byte file gets written to the destination on local disk, called `dataset_a` in my case. Since that's not a directory, you get the following error when you try to write the files inside that `dataset_a` subfolder.
[Errno 20] Not a directory: 'stanford/stanford/dataset_a/dataset_a_Summary.csv'
You can work around by creating the local directory structure manually and downloading the leave files only, but that's quite tedious.
### Related command
az storage blob download-batch
### Errors
[Errno 20] Not a directory
### Issue script & Debug output
Didn't get a chance to do this.
### Expected behavior
make directories instead of zero-byte files.
### Environment Summary
az --version
azure-cli 2.75.0
core 2.75.0
telemetry 1.1.0
Dependencies:
msal 1.33.0b1
azure-mgmt-resource 23.3.0
Python location '/opt/az/bin/python3'
Config directory '/home/christopherbare/.azure'
Extensions directory '/home/christopherbare/.azure/cliextensions'
Python (Linux) 3.12.10 (main, Jun 24 2025, 10:15:18) [GCC 13.3.0]
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.