@echo off if not exist %1* goto notfound cd %1* if exist %1-* goto subdir cd .. if exist %1-* goto rename goto done :rename if exist %1 goto done move %1-* %1 >NUL goto done :subdir move %1-* ..\%1 >NUL cd .. goto done :notfound echo %1 not found! :done