Can I set up searches using variable parameters?

Thanks. Ok, I got it now that you want to create Smart Groups (I was under the impression that you wanted to write names or links of search results into a TOC, e.g. a Markdown TOC record, thus the confusion).

Take a look at Script: Create or change smart group(s). This script asks for a query and creates a Smart Group in all selected groups. If you modify it a bit and e.g.

  • store your variable in the finder comments or custom meta data of selected groups
  • set the dialog’s default answer to your “default” query (the part that’s static)

then it could be possible to get quite near to what you have in mind, I think.

Personally I use a version of this script where the dialog has an extra button “Templates”. Clicking this opens a “choose from list” dialog with template queries (which are stored in a text file that can be opened from within that dialog). That could make sense for you too.