I'm trying to identify audio files that don't have cover images using a command. My current approach uses the `find` command as follows: `find /srv/media/Music/ -type f -regex '.*.(mp3|flac|m4a|opus)' -exec bash -c 'ffprobe -hide_banner -loglevel error -select_streams v -show_entries stream=codec_type -of csv=p=0 "$0" ' {} ;`. This command outputs 'video' if a cover image is attached but returns nothing if there isn't. I'm looking for a way to modify this command so that it lists all audio files that lack cover images. I attempted to redirect STDERR and STDOUT and use a pipe with `$?`, but couldn't figure it out. I'm consistently getting a list of all files instead of only those without cover images.
3 Answers
Your issue might be with how the bash shell handles input. You could modify your command to include `$@` at the end of the `ffprobe` command. You just need a dummy argument before `{}`, like adding an underscore. This sets the positional arguments effectively in bash and helps you capture the files correctly.
Edit: I initially overlooked the `$0`, so disregard my last suggestion. Sorry about that!
You got it! It’s a subtle but important detail.
Using a loop might simplify things for you. You could try:
```
find /srv/media/Music/ -type f -regex '.*.(mp3|flac|m4a|opus)' |
while read f; do
ffprobe -hide_banner -loglevel error -select_streams v -show_entries stream=codec_type -of csv=p=0 "$f" || echo "No cover: $f";
done
```
This way, if `ffprobe` fails, it will print the filename directly and helps to clarify the process.
A quick alternative you can try is running:
```
ffprobe {} >/dev/null && echo {}
```
This command checks the return status of `ffprobe` and echoes the filename if there's no cover. You can adjust it based on your needs, like checking output instead, but this should get you started!

Thanks for the heads up! I didn't realize I needed that underscore to clarify the variables.