create-folder-structure.sh
Creates local folder structure and optionally downloads files from Azure Blob Storage.Description
This script reads blob paths (typically fromlist-media-files.sh) and creates a matching local folder structure. It can create placeholder files, download actual files in parallel, or just create directories.
Prerequisites
- Azure CLI installed and configured
- Authenticated Azure session (
az login) - Input from
list-media-files.shor similar format
Configuration
Edit these variables in the script:Usage
Basic Syntax
Parameters
-
BASE_DIR (optional, default:
media-files)- Directory where structure will be created
-
MODE (optional, default:
placeholder)placeholder- Create empty placeholder filesdownload- Download actual files from Azureskip- Create only directories, no files
-
PARALLEL (optional, default:
10)- Number of parallel downloads (only for
downloadmode)
- Number of parallel downloads (only for
Examples
Create Placeholder Files
Download Actual Files
Download with High Parallelism
Create Only Directories
Custom Directory Name
Output
Placeholder Mode
Download Mode
Features
- Parallel Downloads: Downloads multiple files simultaneously for speed
- Smart Fallback: Uses GNU
parallelif available, otherwise uses background jobs - Progress Tracking: Shows real-time progress with ✓ and ✗ markers
- Error Handling: Creates placeholder for failed downloads
- Flexible Modes: Choose between placeholder, download, or directory-only
Performance
Download Speed
- Default: 10 parallel downloads
- Recommended for fast connections: 15-20 parallel
- Recommended for slow/unstable connections: 5 parallel
Optimization Tips
Error Handling
Failed to Fetch Storage Key
az login and verify access to storage account
Failed Downloads
Files that fail to download will:- Show
✗ Failed: path/to/file - Create an empty placeholder file
- Continue processing other files
Command Line Too Long
The script handles this automatically by using background jobs instead ofxargs when needed.
Troubleshooting
No Files Created
- Verify input format matches expected pattern (contains
→ https://) - Check Azure credentials:
az account show
Slow Downloads
- Reduce parallel count: use 5 instead of 10
- Check network connection
- Verify Azure region latency
Permission Denied
Advanced Usage
Resume Failed Downloads
Selective Download
Related Scripts
- list-media-files.sh - Generates input for this script