I have a bash script that creates page bundles… but it does not locate the images of your bundle and copies them over…
#!/bin/bash
for FILE in *.md
do
# remove the last dot and subsequent chars to name the folder from the .md
DIR="${FILE%.*}"
mkdir -p "$DIR"
mv "$FILE" "$DIR"
done
find ./ -iname '*.md' -execdir mv -i '{}' index.md \;
go into posts and run it from there and it will create page bundles for all .md files.
for FILE in *.md
do
# remove the last dot and subsequent chars to name the folder from the .md
DIR="${FILE%.*}"
mkdir -p "$DIR"/images
mv -f "$FILE" "$DIR"/index.md
done
But, in order to move all the images from the default /static/img/ directory to the new images directory, you will probably need to write a script in the language of your choice that will capture all occurrences of strings like ![whatever](/img/whatever.jpg) in the newly created index.md and execute the move.
AFAIK, standard *nix tools like grep, awk or sed are not suited to easily capture multiple occurrences.
in: look for a file or bunch of files depending on this input glob
out: create the bundles in this output directory
in_img: root directory for input images. Default static. If you keep your images in assets, change that here.
out_img: sub-directory for images in the output bundle
Note this does NOT delete or move any files, for the safety of your file-system - it creates new files/copies in out instead. If you are happy with the run/conversion, you can delete the image files yourself with the handy list of --> processed images it gives you at the end of processing on the console output. I also didn’t want to make assumptions about whether an image is in use on multiple pages, or other pages outside of the input glob scope, so another reason for not moving/deleting but copying instead.
Tested on MacOS and Linux - I tried to make sure not to make POSIX assumptions about paths, so it should work on Windows too (assuming you’re using powershell or WSL), but I haven’t actually tested this so no promises!