19

Hey, I'm trying to create a pipeline that takes files from a flat directory source/ that contains files with names formatted as yyyy-mm-dd-some-file-name.md and processes them with the output being created in destination/yyyy/mm/dd/some-file-name.md. I managed to string together an ugly script that converts the source path to destination path, but the problem is that make says that there is no rule to make the target. Here is my code so far:

SOURCE := $(wildcard source/*.md)
DESTINATION := $(foreach f,SOURCE,destination/$(shell echo $(notdir $(f)) | sed -E 's/^([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md$$/\1\/\2\/\3\/\4.md/'))

$(DESTINATION): $(SOURCE)
	@mkdir -p $(dir $(shell echo $(notdir $@) | sed -E 's/^([0-9]{4})-([0-9]{2})-([0-9]{2})-(.*)\.md$$/\1\/\2\/\3/'))
	/bin/bash ./myscript.sh $< > $@

I believe that make sees that there are no target directories yet and just aborts the rule, but I'm not knowledgeable enough and just starting out with that tool. I would appreciate some guidance if any of you folks know a bit of Make.

you are viewing a single comment's thread
view the rest of the comments
[-] eleijeep@piefed.social 3 points 1 week ago

Well spotted, thanks. I replied further down the thread to OP with another option for doing this in Make, if you'd like to spot any bugs in that one too ;)

this post was submitted on 16 Aug 2026
19 points (100.0% liked)

Programming

28283 readers
165 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS