Folding and unfolding of magnetic skyrmion strings in higher dimensions