Zip each file from a flat view into a separate archive

A friend wanted to compress each file in a nested folder structure into a separate zip file that still resides in the same structure, e.g. turn something like this

folder1\file1.txt
folder2\file2.txt
folder2\file3.txt

into

folder1\file1.zip
folder2\file2.zip
folder2\file3.zip

where each zip file contains just the corresponding .txt file in its root with no other directories.

I think I succeeded in making a button to do this, refraining from using any external programs. Just turn on flat view mixed (no folders) in the source lister, select the files you want to turn into .zip, and press the button. For safety reasons this does NOT delete the original files. The deletion can be easily done manually, using flat view.

It took me a while to figure out how to access the path of files in flat view, so I will share the button here (the key was to use {filepath$|..}).

<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>Add To &amp;ZIP (each file separately)</label>
	<tip>Add each selected file to a separate ZIP file</tip>
	<icon1>#addtozip</icon1>
	<function type="normal">
		<instruction>@nodeselect</instruction>
		<instruction>Copy {filepath$} ARCHIVE=single,keepfolder TO {filepath$|..} CREATEFOLDER={file$|noext}</instruction>
	</function>
</button>