How can I list audio files without cover images using a command?

0
1
Asked By CuriousGamer42 On

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

Answered By TechieTina01 On

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!

CuriousGamer42 -

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

InfoSeeker77 -

You got it! It’s a subtle but important detail.

Answered By CodeJunkie99 On

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.

Answered By SoundWizard88 On

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!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.