PS to my own (which I actually tried to cancel):
While there are free scripts out there, this question has a lot of
different variations and issues that you could run into that would take
a lot of time to work around, so it's probably worth just biting the
bullet and paying for MacLinkPlus (that Michel linked), which is a more
extensive program that should already have taken all these issues into
account.