My Blog

A classic static blog

commands-find-music-files-termux

To find all .mp3 files on the SD card in Termux CLI, follow these steps:

  1. Grant Storage Permissions to Termux

· Open Termux and run: bash termux-setup-storage · Allow Termux access to your storage when prompted.

  1. Navigate to the SD Card Path

· After setup, Termux creates a ~/storage directory. External SD cards are typically symlinked here as external-1, external-2, etc. · Check available storage links: bash ls ~/storage · For most devices, the external SD card is at external-1.

  1. Search for .mp3 Files

· Use the find command on the SD card path: bash find ~/storage/external-1 -type f -iname "*.mp3" · -type f: Only search for files (not directories). · -iname “*.mp3”: Case-insensitive search for .mp3 files.

  1. Handle Errors (Optional)

· To suppress “Permission denied” errors: bash find ~/storage/external-1 -type f -iname "*.mp3" 2>/dev/null