This did the trick, using %%~dpG also had the backslach so i also had to remove that.
%%~dpG
CD /d %searchFolder% FOR /D /r %%G in ("?earch") DO set dir=%%~dpG set dir=%dir:~0, -1%
2.1m questions
2.1m answers
60 comments
57.0k users