rerouting water pipes, is this way ok?

Hi all, attached is a depiction of what I want to do. Left is the original wall with the yellow lines depicting 2 water pipes (one hot, one cold) inside the wall. These pipes go to supply water to a washroom on the 2nd floor. On this wall, I want to create an opening as indicated on the right image. To do this, is it ok for me to reroute the pipes as shown on the image? This is the easiest way I can think of.