Hi,
I've got 2 files:
pins.txt = single column of 7digit pincodes, one per line.
users.txt = multiple columns (comma delimited), first of which is 7 digit pincode
Users file is archive of all user accounts ever created, and pins file is just current accts (far fewer lines than users)
I'm trying to find a way to generate a list of the lines in the users file based on the pins in the pins.txt file.
my (limited) VB logic has me looking for a solution along these lines;
For each pincode in pins.txt
find pincode in users.txt
copy line from users.txt to newfile.txt
Next
Impressive huh! It seems an incredibly simple request, and one that I can easily achieve manually using copy, paste, and F5 in TP, but I've got hundreds of pincodes to process so I'm trying to find an automated solution.
Any scripting guru's have any ideas please?
TIA,
Rupert
Generate File based on search
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Jens Hollmann
Re: Generate File based on search
I like scripts. Put this in a file called "doit.cmd" (or whatever you like):
@echo off
for /F %%p in (pins.txt) do findstr /C:%%p users.txt
Calling "doit" in the directory where "pins.txt" and "users.txt" are will type all the lines from users.txt with valid pin codes. With "doit >ValidUsers.txt" you can pipe this output in a new file.
For an explanation read the help about for and findstr. I just use these very often.
Oh btw, this is working under my Windows NT. The Windows 9x DOS-Box might not be able do do this, I don't know. There are some improvements in the NT DOS-Box.
HTH
Jens
@echo off
for /F %%p in (pins.txt) do findstr /C:%%p users.txt
Calling "doit" in the directory where "pins.txt" and "users.txt" are will type all the lines from users.txt with valid pin codes. With "doit >ValidUsers.txt" you can pipe this output in a new file.
For an explanation read the help about for and findstr. I just use these very often.
Oh btw, this is working under my Windows NT. The Windows 9x DOS-Box might not be able do do this, I don't know. There are some improvements in the NT DOS-Box.
HTH
Jens