It's been awhile since I did any real bash scripting so I asked ChatGPT to do it and was instantly given a working solution. Was gonna do a half hour of manual editing while I watched TV, but now I don't have to. Nice!