#!/usr/bin/zsh if ! command -v "gallery-dl" &> /dev/null; then echo 'The "gallery-dl" command is necessary in order to run the script, but was not found.' exit 1 fi media_url=$1 gallery-dl $media_url cmd_exit_code=$? if [[ $cmd_exit_code -ne 0 ]]; then printf "\n" echo "[ERROR] `basename $0`: Could not download url \"$media_url\"" echo "[ERROR] Exit status: $cmd_exit_code" exit 1 fi find gallery-dl -type f -exec mv '{}' . \; rm --recursive gallery-dl