I’m on a mac, and used this variant for individual sets of files:
# Assumes bilingual files like name.lang.md
# Get the first argument which should be just the base filename
for FILE in $1*.md
# get basename from .md file to make folder
# get name with lang
# get lang string
# make the folder
mkdir -p "$DIR"
# move the files into the folder and rename
mv "$FILE" "$DIR/index.$LANG.md"
ls -la "$DIR"
You might notice it will do the
mkdir for every loop, which is not needed but, because of the
-p switch, the folder gets created on only the first iteration. So it creates it the first loop, then fails to create it on subsequent loops. It’s an assumption but, probably good enough.
I put that in a file
bundle.sh in my
content/pages folder, and set it to executable with:
> chmod +x bundle.sh
Then assuming there are two files like
about.ja.md, I ran it like this:
> ./bundle.sh about
For more info on how this is working, look into “bash parameter substitution”.
If you are editing the script and want to figure out a variant, start out with
echo instead of the
mv commands, so that you can see how the script is working. Like: