Split input

  • Thread starter Thread starter Sheldon
  • Start date Start date
S

Sheldon

I have a batch file that takes two email addresses as inputs. How can I
split the email addresses into variables for usernames and variables for the
domain names?
 
Sheldon said:
I have a batch file that takes two email addresses as inputs. How can I
split the email addresses into variables for usernames and variables for the
domain names?

Perhaps this will work (tested only on XP):


@echo off

:next
(set _email=)
(set/p _email=enter an _email address: )
if not defined _email goto:eof
for /f "tokens=1,2 delims=@" %%F in ('echo/%_email%') do (
set _user=%%F
set _domain=%%G
)
set _
echo/
goto:next
 
Al Dunbar said:
Perhaps this will work (tested only on XP):


@echo off

:next
(set _email=)
(set/p _email=enter an _email address: )
if not defined _email goto:eof
for /f "tokens=1,2 delims=@" %%F in ('echo/%_email%') do (
set _user=%%F
set _domain=%%G
)
set _
echo/
goto:next

That's excellent. Works fine on Windows 2000 Server and 2003 Server.

Thanks very much for your help.
 
Back
Top