How to teleport all players from a specific world into another world?

I think it should be possible using the /execute command.

/execute in <toDimension> run tp @a[nbt={Dimension:"<fromDimension>"}] <location>