Notenik Knowledge Base

9.4 Merge Commands  ↑

9.4.16 copyimages command

The copyimages command can be used to copy local image files from a content collection to an output website folder.

The command line should appear as follows:

<?copyimages?>

The images to be copied will be obtained from the last field output via a merge variable with a modifier of Markdown to HTML - O, so this command line should normally immediately follow the line containing the =$body&o$= string.

Any local image files referenced in the input will be copied to the output folder identified by the script command identifying the webroot to be used by the template, preserving any folder structure.

So an image file identied by a Markdown line such as the following:

![Sample image file](images/sample.jpg)

… would be copied to images/sample.jpg within the output web folder.

This command can be used in conjunction with the File Name - F variable modifier to convert normal macOS local image file names (with spaces, capital letters, etc.) to web-friendly file names.

See the following example for how this might be used within a merge template.

=$body&fo$=
<?copyimages?>

So, in this case, a local image file at “images/Herb with Hank.jpg” would be copied to 'images/herb-with-hank.jpg`' within the output web folder.

Note that the copyimages command will copy to the top of the output folder, as specified by the webroot action, and if the output command is writing to a lower level folder, then the f variable modifier before the o modifier will also cause a relative path to the top level folder to be inserted at the beginning of each image’s source path.


Next: 9.4.17 include command