Skip to content

Instantly share code, notes, and snippets.

@br4instormer
Created November 28, 2024 19:01
Show Gist options
  • Save br4instormer/ad8a66e91ea6ed5d30d423758ced4ce2 to your computer and use it in GitHub Desktop.
Save br4instormer/ad8a66e91ea6ed5d30d423758ced4ce2 to your computer and use it in GitHub Desktop.
Collect all bandcamp links from flac files on nested directories
#!/usr/bin/env bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
LINKS=()
for dir in */
do
file=$(find "./$dir" -name "*.flac" -print -quit)
if [ "$file" ]
then
comment=$(metaflac --show-tag=COMMENT "$file")
if echo "$comment" | grep -q "COMMENT=Visit "; then LINKS+=("${comment#"COMMENT=Visit "}"); fi
fi
done
sorted_links=$(printf '%s\n' "${LINKS[@]}" | sort -u)
echo "${sorted_links[*]}"
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment