To be honest, I don't do much with gsub, etc. However, this snippet seems to work for me:
local clip = "S:\\Test\\Folder\\File.txt"
s = string.gsub(clip,"S:\\"," P:\\Structure1\\Structure2\\")
acMessageBox(s)Though I'm not sure if that's too simple based on your specific requirements.