Extract number from string in batch file

后端 未结 4 670
余生分开走
余生分开走 2021-01-07 06:54

From a batch file I want to extract the number 653456 from the following string:

C:\\Users\\testing\\AppData\\Local\\Test\\abc123\\643456\\VSALB         


        
4条回答
  •  难免孤独
    2021-01-07 07:05

    @echo off 
    setlocal EnableDelayedExpansion
    set "string=C:\Users\testing\AppData\Local\Test\abc123\643456\VSALBT81_COM"
    
    for /L %%d in (0,1,9) do set "string=!string:\%%d=\ %%d!"
    for /F "tokens=2" %%a in ("%string%") do for /F "delims=\" %%b in ("%%a") do echo Number: [%%b]
    

提交回复
热议问题