X-ray Ptychography is a high-resolution coherent diffraction imaging method, which has been widely used in the third generation of synchrotron radiation sources. In this method, diffraction images are collected with a series of probe incident positions on an extended sample with partial overlapping between neighbored exposure areas. Accurate location information of the probe is very crucial to obtain high-resolution reconstruction images in experiment. However, the motor movement errors are usually unavoidable, which are caused by thermal drift or mechanical inaccuracy. We proposed an effective method to correct the scanning position errors, which combined the Fresnel CDI algorithm and the image registration method. The feasibility and robustness of the algorithm have been verified by both simulation and xray experiments.