
Craig Sanders wrote:
yep. another minor variation is to write it something like the following, so that the script can take the default TITLE as the first ARG on the command line, defaulting to 'unknown' if not specified.
export TITLE=${1:-unknown}
Nod, I tend to adopt the style I used because the usage then becomes logical (i.e. by name) rather than positional, so that when you have umpteen variables, the user can specify exactly/only the ones they care about. getopts (bashism) is the other way I often use, but it's inherently limited to single-char variable names, which is a bit of a downer. See start of http://cyber.com.au/~twb/.bin/ru for example.
it's hard to see any benefit in using find here, though. with -maxdepth 1, you may as well just use 'for filename in *.mp3; do...', and have a much easier to read script
for filename in *.mp3 ; do id3ed -isq "$filename" id3ed -q -s "$TITLE${0:5:4}" "$filename" id3ed -isq "$filename" echo "$filename" done
Agreed; I'd have done it that way if I'd initially noticed he didn't want to recurse; when I did, I just lazily added maxdepth.