0

I have a script:

C:\"Program Files (x86)"\Dell\"Command Configure"\X86_64\cctk advsm --report=All | findstr /c:"Current speed" >> %LOG_FILE_NAME%

which gives following output:

Current speed                : 3101 rpm

I just need the actual value "3101" not the whole line. How can I get this?

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • 1
    Does this answer your question? [How to set commands output as a variable in a batch file](https://stackoverflow.com/questions/6359820/how-to-set-commands-output-as-a-variable-in-a-batch-file) – Squashman May 11 '21 at 21:46

2 Answers2

0

for loops are used for this:

for /f "tokens=3* delims=: " %%i in ('"%programfiles(x86)%\Dell\Command Configure\X86_64\cctk" advsm --report=All ^| findstr "Current speed"') do (echo %%i)>>%LOG_FILE_NAME%
Gerhard
  • 22,678
  • 7
  • 27
  • 43
0

Untested idea, but perhaps it would be simpler still if you just report the value you want in the first place!

@For /F "Tokens=4" %%G In ('^""%ProgramFiles(x86)%\Dell\Command Configure\x86_64\cctk.exe" Advsm --Report^=C^"') Do >>"%LOG_FILE_NAME%" @Echo %%G

If C doesn't output what you want then you'd have to use Report=All and search for your line. You can use find.exe for that:

@For /F "Tokens=4" %%G In ('^""%ProgramFiles(x86)%\Dell\Command Configure\x86_64\cctk.exe" Advsm --Report^=All ^| %SystemRoot%\System32\find.exe "Current speed"^"') Do >>"%LOG_FILE_NAME%" @Echo %%G
Compo
  • 36,585
  • 5
  • 27
  • 39