find /your/mp3/directory -type f -name "*.mp3" -exec test -f "/your/mp3/directory/$(basename -s .mp3 {}).txt" \; -exec mp3splt -A "/your/mp3/directory/$(basename -s .mp3 {}).txt" {} \;
This one liner should still work, even if your file names have spaces in them because find
now looks at each individual match, not the entire output. Using a for loop with the results of find
would create a lot of extra pieces of the file names because spaces separate the arguments. However, this single command is harder to read than using a for loop.
The idea behind this one is that search operators in find
evaluate to true or false. The first exec
tells find
to run the second exec
only if the file exists. If the file doesn't exist, it just ignores it.