Batch function for removing trailing backslashes -
i want function remove last slash/slashes, write code multiple times:
if %variable:~-1%==\ set variable=%variable:~0,-1% so i'll have smth this
set var1=c:\folder\ call :removetrailingbackslash var1 echo %var1% - should see "c:\folder" here
@echo off setlocal set var1=c:\somewhere\\\\\\\\\\\\ call :removetrailingbackslash var1 echo var1=%var1% goto :eof :removetrailingbackslash if not defined %1 goto :eof setlocal call set $_=%%%1%% if %$_:~-1%==\ endlocal&call set "%1=%%%1:~0,-1%%"&goto removetrailingbackslash goto :eof this procedure should remove trailing backslashes. how works, i'll leave exercise reader :)
Comments
Post a Comment