Here is a tip to remove a substring via batch command For example: If I'd like to remove file extension name from Install .wim to Install We can try below command: Test.cmd SET WINPE=%1 echo %WINPE% SET WINPE=%WINPE:.wim=% echo %WINPE% Input: Test.cmd Install.wim Output: Install REF: http://www.dostips.com/DtTipsStringManipulation.php