Reputation: 43
I wish to have a command or script that will execute the test feature of flac on all flac files in a folder and its sub-folders. (i.e. $ flac -t music_file.flac)
I've tried using
find . -name "*.flac" -exec flac -t '{}' \;
and it works, however the flac test function also writes a copyright/warranty output before testing each file, making it difficult to clearly see the result of 'ok'.
I've also tried using
for file in 'ls *.flac'
do
flac -t $file
done
which works much neater (only writes the warranty/copyright statement once initially) but does not recursively act on sub-folders.
Could I request some help in improving this?
Upvotes: 4
Views: 2570
Reputation: 11
I get no credit for this, but I think I found a command here which seems to do exactly what the orginal poster wants and which works better for me than the ones proposed here.
find -type f -iname '*.flac' -print0 | xargs --null flac -t
One quibble with this command is that in the one instance I've tested so far, it processes the files in a seemingly random order. (But the same was true with the commands here.) Also, if there are very many files, I'm not sure it will be easy to spot the errors among all the okays. The author of the command recommends adding -w and -s switches to suppress everything except errors, but that seems to be just what the original poster wants to get away from.
Upvotes: 1
Reputation: 9426
I'm not sure if it's the most an elegant solution, but you can use your original command with grep to exclude bits you don't want. So if you wanted the list of files that were tested along with the status, you could search for:
find -name "*.flac" -exec flac -t '{}' \; |& grep "\.flac"
'&' is important since it seems flac outputs most stuff to stderr.
Upvotes: 3
Reputation: 10254
-R, --recursive list subdirectories recursively
You can try this:
for file in 'ls -R *.flac'
do
flac -t $file
done
Upvotes: 0
Reputation: 96934
You can pass --silent
/-s
to flac
and it will not include the copyright info, etc., in the output. Note, however, that it will also not show anything when the file is ok, only outputting if it is not ok.
Upvotes: 2