Thanks to all for the suggestions. I actually oversimplified the situation a little bit (this repo has multiple projects with trunk, branches, and tags directories underneath them), which makes the script a little more complicated. But the concepts presented so far have given me a path forward. I'll post the results once I have it working (hopefully by the end of this week).
Thanks again, Alfred