Hi Craig- Yes! That's the answer. (Sort of. Almost definitely because you're going to pay in one way or the other.)
There is no way to have a tenant move out of your purchased property for free if you want them to leave. In some very rare circumstances you might not have to pay them any money directly (Very, very rare) but you will be taking a tremendous risk to force them out right away without the assistance of an attorney if you aren't an attorney yourself who has practiced real estate tenant law in SF for at least five if not ten years. You also might get really lucky and they just happen to move out when the property is sold.
In any realistic circumstance, you will need an attorney to make sure things are done properly and you do not raise an enormous liability as a property owner for removing a tenant who successfully sues you after the fact for improper or illegal evictions. Don't go there!
For many condominiums and single families built after 1979 on the date rent control kicked in, this is a straightforward process and the costs and associated problems are minimal. Anything after that, if not in all circumstances, requires a real estate attorney WHO SPECIALIZES IN SAN FRANCISCO TENANT LAW.
Bottom line: It's going to cost you money in almost any foreseeable circumstance. Whether it's time lost while waiting for the process to occur legally or actual eviction payments. You're going to need assistance from the aforementioned real estate attorney, flexibility and potentially a great deal of patience to see the process through to completion.
There is a good reason why tenant occupied properties sell for less in San Francisco where the market is very active and in general very knowledgeable about the problems that come up.
Contact me if you'd like to know more because this is just scratching the surface! There is tremendous potential value in these properties if you have a good understanding of the situation before you buy. Thanks, Matt