0

I'm trying to get a list of every .wav file on my Mac (or in a specific folder and all its subfolders) whose length is less than 10 seconds, how would I go about this?

1

Figured it out:

Click Finder in the dock, then when the window opens, press cmd + w to close the window;

Press cmd + f to open a Finder search window, a bar should appear where you can change parameters.

Change the first bar to "Kind is Music All"

Press the + button on that bar;

Click the leftmost box and click "Other"

In the window find "Duration" and check its box, and find "File extension" and check its box

Make the new bar read "Duration is less than hours minutes 10 seconds" Add another bar and make it read "File extension is wav"

Done 👍

0

you can use the included command afinfo on mac in combination with awk and sort:

afinfo ~/Music/drumloops/* | awk '/File:/ { song=$2 } /estimated duration/ { print $3, song }' | sort

this will give you a list like this:

4.197823 /Users/hyph/Music/drumloops/hot_pants.wav
4.231837 /Users/hyph/Music/drumloops/give_it_up_or_turnit_a_loose.wav
4.282630 /Users/hyph/Music/drumloops/fools_gold.wav
6.573061 /Users/hyph/Music/drumloops/assembly_line.wav
7.826939 /Users/hyph/Music/drumloops/amen_brother.wav

drawback: this doesn't seem to work with spaces in filenames.

there are other ways with the MediaInfo or SoX software packages, but they're slightly more complex to learn.

I'm currently digging how to fix the "spaces" problem and how to search through all child folders.

edit: props for a solution with built in spotlight search. will probably avoid some headaches trying to use awk etc.

1
  • In bash, i'd put "$2" and "$3" to fix the spaces issue, not sure if it'd work on the mac's shell tho. Mar 19 '17 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.