Home > other >  Remove comma from variable in CMD
Remove comma from variable in CMD

Time:09-17

How are you all doing?

I made a batch file that gets the memory usage of a process that has a specific PID... Here is the code:

@Echo off

REM Get memory from process using tasklist
for /f "tokens=2 delims=," %A in ('tasklist /svc /fi "SERVICES eq .Service02" /FO csv /NH') do ( 
    REM Store PID on a variable
    @Set "pidSlv02=%~A"
    REM Get memory usage from process with that PID
    for /f "tokens=5 delims= " %B in ('tasklist /fi "pid eq %pidSlv02%" /NH') do (
    REM Store mem value on another variable
    @Set "memSlv02=%~B"
    REM Remove commas from variable
    @Echo %memSlv02% K
    )
)

So, the output is:

1,407,356

Now, i need to convert that number to be 1407356

I did not come here directly. I already tried a couple of things but without success. Im still very new and learning CMD/batch scripts... Didnt even know t was possible to do so much on Windows. Thought it was only possible on Linux. So please don't be angry with me if i dont understand something. Im trying my best!

  • Related