With a typical 2TB drive I would have four to five fixed partitions of about 500GB each
Today
I have migrated to APFS and I have many, many more partitions per drive.
I personally do not like to have drives mounted if I am not using them,
As something like Spotlight grabs them and will not let them go
Some research of the forum shows that the macros referenced below could be modified.
Requirement
Let us say I know I am going to backup to EXTU33CC
And I have attached the EXTU33 external drive
I need a macro that unmounts all external (drives)/partitions starting with EXTU33,
But leaving EXTU33CC (passed as prompt/parameter) mounted
Also making them inaccessible to the system temporarily is a little extra data protection.
Unless there were more than a couple of dozen external drives, I would prefer to explicitly repeat the same simple action for each drive, for instance this in an Execute Shell Script action:
The quotes around the drive name are just there as standard practice and are not needed unless the drive name contains spaces or other characters that would confuse the shell.
Cleverer solutions could match on regex, but why be clever (K.I.S.S. principle), unless there are unknown factors here, such as, perhaps, drive names being changed often.
Specifying the drive names explicitly means no chance of surprises or bugs, and you will have a list of your drives in the macro (one drive in each action) so you can enable and disable each action according to changing need, with no need to modify a regex string or revisit another solution which may be unnecessarily "general purpose".
Will think about your solution, but the reason I posted was I was expecting a regex solution, which would take me personally a very long time to work out.
I have also searched the internet and can find no macos parameter that "disables" automount when you attach a disk drive.
I also have the Jettison app, which was my idea/concept and subsequently developed by Jon Gotow of StClairSoftware. See Jettison .
Jettison unmounts all external drives, but I may have several attached and wanted only to unmount the partitions on a specific external drive,
In case you don't know of it: the Regex101 site is very useful for testing regular expression patterns.
I think this will be suitable:
EXTU33(?!CC[^\w]).*
That will match any string that begins with "EXTU33" unless that is followed by "CC"… unless that is followed by any character in the range A – Z, a – z or 0 – 9.