TwinHeadedEagle
TwinHeadedEagle

Reputation: 41

Batch file extract string

I know this has been asked numerous times, but I've been researching for like 2 hours and still can't do that.

I need a batch script to extract a string from a file.

The content of the file is this:

C:\Windows\system32\tasks{7D7A0547-0D79-0805-0A11-0B780D08110D}

I want to extract this part:

{7D7A0547-0D79-0805-0A11-0B780D08110D}

I tried it with for /f command and all kinds of options and searches, but I just can't do it.

TIA

Upvotes: 1

Views: 342

Answers (2)

user6811411
user6811411

Reputation:

@echo off
for /f "tokens=2 delims={}" %%A in (
  'findstr "{[0-9A-F-]*}" "X:\path\yourfile.ext" '
) Do Echo %%A

Upvotes: 0

npocmaka
npocmaka

Reputation: 57252

for /f "tokens=2 delims={}" %%# in ("C:\Windows\system32\tasks{7D7A0547-0D79-0805-0A11-0B780D08110D}") do echo {%%#}

?

Upvotes: 1

Related Questions