Make page bundles out of JPG files (Batch script)

A simple script to take a directory of JPG files, and created page bundles based on the file’s name. The following code creates two files in each page bundle, one for English, and then one for Greek. The YAML front matter is specific to my theme, so you may want to change what happens there.

For Windows people unfamiliar with batch scripts: take the following code, paste in Notepad and save [ Save as type: All Files (*.*) ] with the .bat extension in the folder where you want this to happen. Double-click on the .bat file to run, and always be cautious of running batch scripts. Any line that starts with rem is a comment and does nothing.

@echo OFF

rem loop through all JPG files
for %%f IN (*.jpg) DO (
	rem make a new directory with the same filename
    mkdir %%~nf
    rem move file the new directory
    move %%f %%~nf/%%f
    rem go inside the new directory
    cd %%~nf
    rem generate YAML frontmatter and save as
    echo ---
    echo directURL: %%f
    echo cover: %%f
    rem date is not returned consistently across locales
    rem echo date: %%~tf
    echo ---
    ) >
    rem create file in another language with the same content
    rem return back to the working directory
    cd ../

In Gist:

An example of the front matter YAML created:

directURL: we_are_gonna_need_a_bigger_flamingo_float.jpg
cover: we_are_gonna_need_a_bigger_flamingo_float.jpg