Skip to content

Stop reinventing `make` in your scripts

1 min read

From time to time, I find myself writing scripts like this:

Terminal window
for file in *.mp3; do
ffmpeg -i "$file" "${file%.mp3}.opus" & # run in parallel
done

Then I want more, controlling the number of processes or something.

However I realized I’m actually reinventing make at last.

So here is the makefile equal to the above script.

SRCS = $(wildcard *.mp3)
OBJS = $(SRCS:.mp3=.opus)
%.opus: %.mp3
ffmpeg -i $< $@
out: $(OBJS)
.PHONY: out