You are here:

Excel/Sorting lines in one document into search-term-entitled smaller documents.


Jonathan wrote at 2013-11-06 14:36:55
So far I have:

@echo off

set RESULT_FILE="result.txt"

set /p "var1=Enter the String to Find: "

pushd %~p0

type NUL > %RESULT_FILE%.tmp

for /f "delims=" %%a in ('dir /B /S *.txt') do (

   for /f "tokens=3 delims=:" %%c in ('find /i /c "%var1%" "%%a"') do (

       for /f "tokens=*" %%f in ('find /i "%var1%" "%%a"') do if %%c neq 0 echo %%f


) >> "%RESULT_FILE%".tmp

move %RESULT_FILE%.tmp %RESULT_FILE% >nul 2>&1

:: Open the file



I want to actually SAVE the file rather than open it, and I want the filename to be "searchterm.txt"

Also, I have a list of search terms. I could make a bat file for each, I suppose. Or could "Enter string to find" allow several terms?

Thank you.


About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts




Can answer basic worksheet related questions like formulae usage, connecting to RDBMS from server to extract rows from tables, basic macro construction, pivot table creation, dynamic updation of worksheet data from Server RDBMS..


3 years

©2017 All rights reserved.