Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to get some text lines from text file by batch?

Featured Replies

Hi to all.

When I run this command

bcdedit /enum all /v > C:\List.txt.

 

List.txt

...Windows Memory Tester---------------------identifier              {b2721d73-1db4-4c62-bf78-c548a880142d}device                  partition=C:path                    \boot\memtest.exedescription             Windows Memory Diagnosticlocale                  en-USinherit                 {7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}badmemoryaccess         YesReal-mode Boot Sector---------------------identifier              {57b67fd0-dbb6-11e3-9719-9cb70d9fba21}description             Grub4DOS...

But there are so many information which I need. I just wan to get some lines below

Real-mode Boot Sector---------------------identifier              {57b67fd0-dbb6-11e3-9719-9cb70d9fba21}description             Grub4DOS

I want creat batch file to do this. Is it impossible?

Can anybody help me? Thanks

 

Is it impossible?

No.

 

I want creat batch file to do this. Is it impossible?

Can anybody help me?

Yes.

Learn about FOR /F with tokens and delims:

http://www.robvanderwoude.com/ntfor.php

http://www.robvanderwoude.com/ntfortokens.php

 

You don't really need a temporary file.

Namely:

@ECHO OFFSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1,2 delims= " %%A IN ('bcdedit /enum all /v') DO (IF %%A.==identifier. SET %%A=%%BIF %%A.==description. SET %%A=%%BIF /I %%B.==grub4dos. GOTO :out):outSET identifierSET descriptionPAUSE

If you really want to create the text file, replace the FOR line with:

bcdedit /enum all /v>C:\List.txtFOR /F "tokens=1,2 delims= " %%A IN (C:\List.txt) DO (

jaclaz

  • Author

Work like a charm.

Thanks so much, Jaclaz. God bless you :)

Edited by congnt92

  • Author

Hi, Jaclaz

I have a question. If menu boot contain Whitespace character, How can I edit your command to get some text which I want. i.e Menu boot is "Grub For Dos". I tried 

IF /I %%B.=="grub for dos". GOTO :out

but It's not working.

Thanks :)

Edited by congnt92

Sure it is not.

"%%B" in that case would be only "grub" as you have delims set to [sPACE] and tokens set to 1 and 2.

Try with tokens=1,* <- the idea of giving you a reference is that you study the syntax, so that you can make changes yourself, but not "random" ones.

Also you need quotes on both sides, like

IF /I "%%B"=="grub for dos" GOTO :out

jaclaz

  • Author

Thank you for your quick reply, Jaclaz

Now I understand what differences between tokens=number and tokens=*.

Have a nice day :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.