Suppose in a batch file, say receive.bat, is called with some arguments. Now receive.bat executes and it needs to process these arguments.
Sometimes (but not always), an argument will end with a trailing slash (e.g.
"C:\a\b\"). The number of arguments is not fixed and the (only) such argument may appear anywhere in the list of arguments.
How can my .bat file remove the
\", for example, to get
I tried the examples below and the 3rd one is not working.
It just said
there should not be a SET here.
SET var=C:\ IF %var:~-1%==\ SET var=%var:~0, -1% @ECHO %var% SET var2="C:\\ IF %var2:~-2%==\\ SET var2=%var2:~0, -2% @ECHO %var2% SET var3="C:\" IF %var3:~-2%==\a" SET var3=%var3:~0, -2% @ECHO %var3%