Batch embed video files to html files (with Automator?) Can the following be done with Automator, or any other tool/script on macOS?


I have multiple video files with various file names (always .mp4).
All video files must be embeded in to separate HTML documents.
The HTML-documents should have the same file name as the video file.
Both files should be placed together in a zip file.
The zip file should have the same name as both the video and the HTML file.


So, if I have the file video-to-html.mp4, I would like to end up with a zip file containing two files:

video-to-html/video-to-html.html
video-to-html/video-to-html.mp4


The contents of the HTML file would look like:

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Lorem ipsum&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;video autoplay controls&gt;
&lt;source src="video-to-html.mp4" type="video/mp4"&gt;
&lt;/video&gt;
&lt;/body&gt;
&lt;/html&gt;


I am not a developer, so I do not understand a lot of coding.
You can accomplish this easily with a short shell script:

#!/bin/bash

for v do
    base=${v%%.mp4}
    cat &gt;&gt;"${base}.html" &lt;&lt;EOF
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Lorem ipsum&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;video autoplay controls&gt;
&lt;source src="$v" type="video/mp4"&gt;
&lt;/video&gt;
&lt;/body&gt;
&lt;/html&gt;
EOF

    rm -f "${base}.zip"
    zip "${base}.zip" "${base}.html" "$v"
done


Save it as a shell script in a convenient place, open Terminal, run chmod +x name-of-script and execute as ./name-of-script *.mp4