There are a number of good alternate solutions in the "I want to delete all bin and obj folders to force all projects to rebuild everything" thread you referred to, but if you want to use this command line it needs tweaking for Release and Debug:
DIR /B /AD /S bin
This says to output all directories (/AD) in and under the current directory (/S) named bin (or obj in the second invocation). You would want to do this for Debug and Release instead of bin and obj.
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S Release') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S Debug') DO RMDIR /S /Q "%%G"
As Stuart says, a batch file (or command line invocation) with those two commands and run from the project root will remove all directories named Release or Debug and their contents. It won't be smart and know that these are the configured release and debug directories for the project.
Using a tool that knows about the project configuration files and acting based on them would be safer. Again there are some ideas on those in the other thread you linked.