I don’t think that works, because the command substitution in "$(…).txt" runs immediately in the current shell.
Aside from that, find -exec doesn’t use a shell to run its command, which means $(…) won’t work without an explicit sh call.
I believe the right command in this style that will work is:
find /my/mp3dir -type f -iname '*.mp3' -exec sh -c \
'test -f "${0%.mp3}.txt" && mp3splt -A "${0%.mp3}.txt" "$0"' \
'{}'';'
However, I would recommend the forfin *.mp3-style solution instead, as to me it’s more readable. (The Bash/Zsh recursive glob (**) syntax can be used if subdirectories are involved.)
I don’t think that works, because the command substitution in
"$(…).txt"
runs immediately in the current shell.Aside from that,
find -exec
doesn’t use a shell to run its command, which means$(…)
won’t work without an explicit sh call.I believe the right command in this style that will work is:
find /my/mp3dir -type f -iname '*.mp3' -exec sh -c \ 'test -f "${0%.mp3}.txt" && mp3splt -A "${0%.mp3}.txt" "$0"' \ '{}' ';'
However, I would recommend the
for f in *.mp3
-style solution instead, as to me it’s more readable. (The Bash/Zsh recursive glob (**
) syntax can be used if subdirectories are involved.)