Skip to main content

list-media-files.sh

Lists all blobs in Azure Blob Storage container with a tree-structured view.

Description

This script fetches all blobs from the specified Azure Storage container and displays them in a hierarchical tree structure with their full URLs. Useful for visualizing the folder structure and getting direct links to files.

Prerequisites

  • Azure CLI installed and configured
  • Access to Azure Storage Account
  • Authenticated Azure session (az login)

Configuration

Edit these variables in the script:
ACCOUNT_NAME="testdinostr"
CONTAINER_NAME="docs"

Usage

./scripts/list-media-files.sh

Pipe to Other Scripts

# Save output to file
./scripts/list-media-files.sh > blob-list.txt

# Pipe to create folder structure
./scripts/list-media-files.sh | ./scripts/create-folder-structure.sh

Output Format

Tree view of blobs:

├── docs/
  ├── ai-insights/
    ├── emerging-failures.webp → https://testdinostr.blob.core.windows.net/docs/docs/ai-insights/emerging-failures.webp
    ├── key-metrics.webp → https://testdinostr.blob.core.windows.net/docs/docs/ai-insights/key-metrics.webp
  ├── analytics/
    ├── environment/
      ├── environment-analysis.webp → https://testdinostr.blob.core.windows.net/docs/docs/analytics/environment/environment-analysis.webp

Done

Features

  • Tree Structure: Displays files in a hierarchical folder view
  • Full URLs: Shows complete blob URLs for easy access
  • Sorted Output: Files are alphabetically sorted
  • Clean Display: Uses tree-style formatting with ├── markers

Error Handling

If the script fails to fetch the storage account key:
Failed to fetch storage account key
Solution:
  1. Ensure you’re logged in: az login
  2. Verify you have access to the storage account
  3. Check the account name is correct

Performance

  • Fetches all blobs in a single API call
  • Efficient for containers with thousands of files
  • Output is streamed, so large lists don’t consume excessive memory

Examples

Basic Usage

./scripts/list-media-files.sh

Save to File

./scripts/list-media-files.sh > media-inventory.txt

Count Total Files

./scripts/list-media-files.sh | grep "→" | wc -l

Filter Specific File Types

./scripts/list-media-files.sh | grep "\.webp"