Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I want to write a batch file that can split words within a string. for example, I have a string "Hello-World". I just want to echo out any characters before the "-". so when I echo out, it would just say Hello.
any help would be appreciated.
Thanks in advance

@echo off & setLocal EnableDelayedExpansion
set str=hello-world
for /f "tokens=1 delims=-" %%a in ("!str!") do (
echo %%a
)
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |