FG
💻 Software

How to extract part of a string in Windows batch file?

Fresh5 days ago
Mar 15, 2026365169 views
Confidence Score0%
0%

Problem

Suppose I have a value such as "Abc_123" that's stored in a variable in a batch (cmd) file. I want to end up with a variable that contains only "123". Is there any built-in way to do this? I'm not terribly picky about the method, or performance, as long as it's built in to a typical Windows (Vista/…

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to extract part of a string in Windows batch file?

Low Risk

Use the substring syntax:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment