In my application, I get a number having leading zeros. I am trying to trim the leading zeros and get the actual number. I tried using /a switch which considers
You can use FOR /F to remove leading zeros.
C:\>SET n=00030
echo off
for /f "tokens=* delims=0" %a in ("%n%") DO echo %a
30
As you can see, the delims is set to 0. This will makes 0 as a delimiter. At the same time with tokens of * this will ensure that the leading 0's will be removed while the rest of the line will be processed (including trailing 0's).
You may refer to this link for more information about removal of leading 0's.
P.S. Do remember to use %%a instead of %a when you are running on batch file in FOR /F.