You are not logged in.
@HobbitJack is using a /bin/sh shebang, presumably to avoid the bash bloat, so they should probably read the "Case Conditional Construct" section of https://pubs.opengroup.org/onlinepubs/9 … hap02.html instead.
Bash == /bin/sh in Arch but most other distributions aren't so foolish.
Para todos todo, para nosotros nada
Offline
In this case it was mostly because this was bodged together several times (this is version 2 lol). Also something of force of Python habit, but this isn't Python. Next time I update it I'll want to merge the argument checking into a case statement, but if I recall I was just adding those ad hoc so whatever came out is what we got here.
I am at least aware of case statements, don't worry! =D
slides massive shell script monstrosities full of bloated case-esac used for data analysis under a rock
Last edited by HobbitJack (2024-12-12 09:06:58)
Astrophysicist and programmer. I like simple things.
Offline
A seasonally-appropriate script that uses "find" to scan through FLAC files, find any with "Christmas" or "Xmas" in the file name and asks if the GENRE tag should add "Christmas" as a GENRE if it is absent.
#! /bin/bash
if [[ $# -eq 0 ]]; then
/usr/bin/find . -regextype egrep -regex '.*(Xmas|Christmas).*\.flac' -exec $0 {} \;
else
GENRE=$(/usr/bin/metaflac --show-tag=GENRE $1)
if [[ ! $(echo $GENRE | /usr/bin/grep "Christmas") ]]; then
echo "$1 does not contain Christmas in GENRE"
read -p "Would you like to add it? [y/n]" answer
if [[ $answer == y ]]; then
NEW_GENRE="$GENRE; Christmas"
NEW_GENRE=$(echo $NEW_GENRE | sed 's/GENRE=//')
echo "New GENRE is $NEW_GENRE"
/usr/bin/metaflac --preserve-modtime --remove-tag=GENRE --set-tag="GENRE=$NEW_GENRE" $1
/usr/bin/metaflac --show-tag=TITLE --show-tag=GENRE $1
fi
fi
fi
Offline