reManager is far better for this use-case [0] instead of these fragile scripts.
[0] https://github.com/rmitchellscott/reManager