How to? best way to compose data for command to use out of presets/variables

Mar 4, 2020

I need to archive certain directories using WINRAR program. I use options to include certain list of documents and exclude certain list of documents from compression. These lists form pairs for each type of directory/files I need to archive, e.g. if I compress c:\docs I include files *.txt, *doc but exclude ~*.txt, ~*doc, ~backup, *.doc (and relevant filesets have names look like "fileset2include-docs" and "fileset-except-docs" or "fileset2include-drafts" and "fileset-except-drafts" - the file names are intentionally long but only one portion of the name changes).

I'd like to be able to easily choose whether to compress not only one directory/set of options but several as well, i.e. if I compress only c:\docs or only c:\drafts it will be one set of options and one pair of filesets, but if I compress both at the same time I don't want to create extra filesets but rather would like to combine the existing ones on the fly as there are some common elements in different filesets and there are some unique as well and I would like to put common elements into separate files rather than to include into each one.

What is the best way to do this ? My current command is (and I currently manually rename filesets into the required names prior to operation):
winrar.exe a -r -s -m5 -md4096 -ep1 -v2g -vn "-hp123" %dp%\%1.doc -x@c:\bat\bad4encrypt @c:\bat\good4encrypt

I understand that for the first bit of the task (sets of pairs of filesets) I should probably try to create on the fly variables (using "set") which will then become the program to execute, e.g. it will replace "c:\bat\bad4encrypt" "c:\bat\good4encrypt" with variables created by appending with %%1 to "fileset-except-" and "fileset2include-"

But for the second bit of the task I also need to combine the content of several filesets into one as well. What is the best approach to do it ?

The files sets contain data line by line, e.g.
copy of*.*