Lionel MM
asked on
Search batch file and replace
I have a list of email addresses (black list) that I want to parse and remove everything except the domain name this is a small sample of the list
n.hardy@konnect-force.com
nancy@justleadgen.com
natural.d@tanya-tech.com
natural.n@realtoryou.com
want to end up with just
konnect-force.com
justleadgen.com
tanya-tech.com
realtoryou.com
The trick is that the number of characters before the @ varies greatly so how can I solve this please. Thanks. Prefer a batch file solution but VB or powershell acceptable too.
n.hardy@konnect-force.com
nancy@justleadgen.com
natural.d@tanya-tech.com
natural.n@realtoryou.com
want to end up with just
konnect-force.com
justleadgen.com
tanya-tech.com
realtoryou.com
The trick is that the number of characters before the @ varies greatly so how can I solve this please. Thanks. Prefer a batch file solution but VB or powershell acceptable too.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WOW great that's more than I asked for so thanks--however when I run it all that happens is that the the email address list open in notepad and when/if I close it another blank one named newlist.txt opens up. This is what I am using
@echo off
setlocal enabledelayedexpansion
(for /f "tokens=2 delims=@" %%d in ('D:\Data\SPAM.txt') do echo %%d) | sort >D:\Data\newlist.txt
set line=
(for /f %%d in ('D:\Data\NewList.txt') do (
if not "!line!"=="%%~d" echo %%~d
set line=%%~d
)) > D:\Data\deduped.txt
@echo off
setlocal enabledelayedexpansion
(for /f "tokens=2 delims=@" %%d in ('D:\Data\SPAM.txt') do echo %%d) | sort >D:\Data\newlist.txt
set line=
(for /f %%d in ('D:\Data\NewList.txt') do (
if not "!line!"=="%%~d" echo %%~d
set line=%%~d
)) > D:\Data\deduped.txt
try the word "type" before the path as in example above... I prefer that way to just listing the path (which would be without the ' ' around it.
Steve
Steve
ASKER
ok that does something but this is what I end up with in C:\Data\deduped.txt
C:\Utils>(
if not "!line!" == "2cjesus.com" echo 2cjesus.com
set line=2cjesus.com
)
2cjesus.com
C:\Utils>(
if not "!line!" == "acumatica.com" echo acumatica.com
set line=acumatica.com
)
acumatica.com
C:\Utils>(
if not "!line!" == "advhpc.com" echo advhpc.com
set line=advhpc.com
)
advhpc.com
deduped.txt
C:\Utils>(
if not "!line!" == "2cjesus.com" echo 2cjesus.com
set line=2cjesus.com
)
2cjesus.com
C:\Utils>(
if not "!line!" == "acumatica.com" echo acumatica.com
set line=acumatica.com
)
acumatica.com
C:\Utils>(
if not "!line!" == "advhpc.com" echo advhpc.com
set line=advhpc.com
)
advhpc.com
deduped.txt
Looks like you don't have @echo off ?
Steve
Steve
ASKER
Thanks
np, you got it working then I presume.
Steve
Steve
Steve
Open in new window