Not so easy as you think and most printers do not have both endstops or know the distance.
Better solution is to print 2 blocks 5 and 10cm. Take the difference in length which equals 50mm planned. Correct stepsnew = stepsOld * 50/distanceMeasured and store it in eeprom using eeprom editor.
Difference because settings can make objects slightly bigger but both blocks should have the same error so you subtract error of same size and get real width.