purpleoak
asked on
Search and replace with Batch
I have a file which contains lines in the following format
"93" "Mr" "Expolink Euorpe Ltd" "Expolink Europe Ltd" "Unit 1 Greenways Business Park" "Bellinger Close" "Chippenham" "Wiltshire" "SN15 1BN" "U" "27FEB06"
what i want to do is do a batch for loop which compairs the first token 93, with another file that is in the same format. I currently open the files with notepad ++ and do a find and replace for the string " " with : then run the following script
for /F "tokens=1 delims=:" %%a in (osc.txt) do (for /F "tokens=1 delims=:" %%t in (ms520test.txt) do if %%a EQU %%t echo %%a:%%t >>results.txt)
This gives me what i want. However the find and replace normally crashes the program as the file has around 200K lines in it sometimes more. I need to be able to do a find and replace batch script or a for loop where the delims can be delims=" "" i have tried to escape the speech marks with the following delims=^" ^"" but that didnt work
Any Ideas?
"93" "Mr" "Expolink Euorpe Ltd" "Expolink Europe Ltd" "Unit 1 Greenways Business Park" "Bellinger Close" "Chippenham" "Wiltshire" "SN15 1BN" "U" "27FEB06"
what i want to do is do a batch for loop which compairs the first token 93, with another file that is in the same format. I currently open the files with notepad ++ and do a find and replace for the string " " with : then run the following script
for /F "tokens=1 delims=:" %%a in (osc.txt) do (for /F "tokens=1 delims=:" %%t in (ms520test.txt) do if %%a EQU %%t echo %%a:%%t >>results.txt)
This gives me what i want. However the find and replace normally crashes the program as the file has around 200K lines in it sometimes more. I need to be able to do a find and replace batch script or a for loop where the delims can be delims=" "" i have tried to escape the speech marks with the following delims=^" ^"" but that didnt work
Any Ideas?
ASKER
Hi Leew
thanks for the quick responce, what im looking to find is " " the find includes the speech marks and the whitespace is a tab. hope this helps.
thanks for the quick responce, what im looking to find is " " the find includes the speech marks and the whitespace is a tab. hope this helps.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks guys for all your help, i had to do a search and replace with t0T0's script then did the for loop as described by oBdA. 1.5 million records took a LONG LONG time to process but it did the job. thank you for your help
ASKER
Thanks for the quick response very very helpful
Great to be of assistance. Thank you for the feedback.
Open in new window