Both can be done via a purpose built-script, but I would not go that way.
A special script did write the categories into the IPTC category field, the lowest categories (lowest level) were written into the IPTC keyword field and some other informations (caption, author,...) were written into the corresponding IPTC fields. (Script: IMatch-IPTC-Skript3)
If you mean legacy IPTC when you say "IPTC", just don't. IIM3 IPTC has been abandoned several years ago. Don't update them directly. For new files the MWG and IPTC recommendations are to
not create legacy IPTC records at all. Only XMP metadata. IMatch does this by default.
If seems that you have a 'backwards' workflow. You enter metadata as categories, and then try somehow (with a script) to get the data out of your categories into the metadata - where they belong anyway.
In IMatch, the standard workflow (if there is such a thing) is to edit metadata in the Metadata Panel. And to edit keywords in the Keyword Panel. When you write back the metadata to your files, IMatch updates the XMP record and optionally also updates the legacy IPTC record in your files.
The Metadata Panel has many features which avoid to much typing. The thesaurus can be used to setup names and captions and to recall them later simple. Many other features as well, including controlled metadata update for thousands of files: Select thousands of files, enter an author, and IMatch updates only the author in all files. You can update massive amounts of files in very short time that way.
If you want to categorize your files by metadata like author you can create a data-driven category. Whenever you add, change or remove the author tag of one of your files, the category will reflect that.
To add, edit, update, change etc. keywords, the beat tool is the Keyword Panel in IMatch. It has many features which make editing keywords for individual files or entire batches a snap. The special @Keyword category will mirror the keywords in your files automatically.
When IMatch "flattens" keywords (transforming them from the hierarchical keyword model IMatch uses internally to the flat (no hierarchy) keyword model used by legacy IPTC and XMP) you can control which level of your keywords gets written to the file. For example, if you have a keyword layout like
WHAT
|- Persons
|- John
You can tell IMatch to write only "John" as a flat keyword. The hierarchical keywords in XMP will always be written full hierarchical.
IMATCH did import automatically some EXIF and IPTC fields into IMATCH properties.
There is a script named "Import Metadata into Attributes" which can do this for you. But why do you mirror metadata in Attributes? IMatch 5 keeps all metadata cached, so there is no performance problem. IMatch 3 could only access legacy IPTC/EXIF data when the image was on-line. IMatch 5 has the info always available. Usually you use Attributes in IMatch 5 for other purposes as metadata which is in the database anyway.