Skip to main content
added 2 characters in body
Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41

As said by op @dbenham There are multiple ways to handle this:

  • In command-line:
for /f usebackq^tokens^=4delims^=^<^> %G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do @echo/%G
  • In bat/cmd file:
@echo off

for /f usebackq^tokens^=4delims^=^<^> %%G in (`wmic volume where "Driveletter like '%C%'"'%%C%%'" get label /format:xml ^| find "VALUE"`)do echo/%%G

Change the formatting to xml and the output will change the encode, after that filter to obtain the desired value in one line and on for loop without additional characters and/or linebreaks.

As said by op @dbenham There are multiple ways to handle this:

  • In command-line:
for /f usebackq^tokens^=4delims^=^<^> %G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do @echo/%G
  • In bat/cmd file:
for /f usebackq^tokens^=4delims^=^<^> %%G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do echo/%%G

Change the formatting to xml and the output will change the encode, after that filter to obtain the desired value in one line and on for loop without additional characters and/or linebreaks.

As said by op @dbenham There are multiple ways to handle this:

  • In command-line:
for /f usebackq^tokens^=4delims^=^<^> %G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do @echo/%G
  • In bat/cmd file:
@echo off

for /f usebackq^tokens^=4delims^=^<^> %%G in (`wmic volume where "Driveletter like '%%C%%'" get label /format:xml ^| find "VALUE"`)do echo/%%G

Change the formatting to xml and the output will change the encode, after that filter to obtain the desired value in one line and on for loop without additional characters and/or linebreaks.

Source Link
Io-oI
  • 8.3k
  • 3
  • 13
  • 41

As said by op @dbenham There are multiple ways to handle this:

  • In command-line:
for /f usebackq^tokens^=4delims^=^<^> %G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do @echo/%G
  • In bat/cmd file:
for /f usebackq^tokens^=4delims^=^<^> %%G in (`wmic volume where "Driveletter like '%C%'" get label /format:xml ^| find "VALUE"`)do echo/%%G

Change the formatting to xml and the output will change the encode, after that filter to obtain the desired value in one line and on for loop without additional characters and/or linebreaks.