setlocal setlocalDisableDelayedExpansion set"param=%~f0" cmd/v:on/cecho(^^!param^^!|findstr/R"[|`~!@%%\^&()\[\]{}+=;',|]*^" endlocal if%errorlevel%EQU0( %ErrLine% echoDisallowedspecialcharactersdetectedinfilepathname. echoMakesurefilepathnamedono