Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Just one more.

15 views
Skip to first unread message

neil.do...@ntlworld.com

unread,
Feb 21, 2005, 4:05:36 AM2/21/05
to
I've decieded to approch this problem another way.

Now the batch file has the whole line but split into two sections
(could be made into one?). As you will see below, each line needs to
add a increment number from '0' upto the last line. Then it needs to
read from a text file (readin.exe) and add each line to the new file
all at the same time.

So, for example.

('', '0', 'Business', 'Business', '', '', '', '', ''),
('', '1', 'Business/Real_Estate', 'Business', '', '', ''),
etc...

Theres a file with a big list of categories (which I won't place on
here - 50mb file) where the batch file extracts the input word, e.g. -
Business. Then ehco's it to a output file called 'breakdown.txt'. so
the 'breakdown.txt' file has only the inputted word/list of categories.

Business
Business/Real_Estate
Business/Real_Estate/Legal
Business/Real_Estate/Legal/Title_Services
Business/Real_Estate/Legal/Title_Services/Title_Insurance
Business/Real_Estate/Legal/Title_Services/Title_and_Escrow
Business/Real_Estate/Legal/Surveyors
Business/Real_Estate/Employment
Business/Real_Estate/Employment/Job_Search
Business/Real_Estate/Employment/Executive_Search
Business/Real_Estate/Employment/Individual_Resumes
Business/Real_Estate/Commercial
Business/Real_Estate/Commercial/Associations
Business/Real_Estate/Commercial/Marketing_and_Advertising
Business/Real_Estate/Commercial/On-Line_Listing_Services
Business/Real_Estate/Commercial/Lenders
Business/Real_Estate/Commercial/Consulting
Business/Real_Estate/Commercial/Economic_Development_Agencies
Business/Real_Estate/Commercial/Business_Brokers
Business/Real_Estate/Commercial/Business_Brokers/National_Companies
etc...

Here's my batch file as it stands. My problem is to make each line have
an increment number, starting from '0', but to also have the list (as
above) on each line.

######################################################
Batch file - testing.bat
Folder - c:\
Output Folder - c:\testing\
######################################################
@echo off
:MAINMENU
CLS
ECHO. Category menu:
ECHO. Arts...............a
ECHO. Business...........b
ECHO. Computers..........c
ECHO. Games..............d
ECHO. Health.............e
ECHO. Home...............f
ECHO. Kids and Teens.....g
ECHO. News...............h
ECHO. Recreation.........i
ECHO. Reference..........j
ECHO. Regional...........k
ECHO. Science............l
ECHO. Shopping...........m
ECHO. Society............n
ECHO. Sports.............o
ECHO. World..............p
ECHO. Quit...............q
ECHO.
ECHO. Please choose a letter:
SET /P letter=

if errorlevel 17 goto next
if errorlevel 16 goto next
if errorlevel 15 goto next
if errorlevel 14 goto next
if errorlevel 13 goto next
if errorlevel 12 goto next
if errorlevel 11 goto next
if errorlevel 10 goto next
if errorlevel 9 goto next
if errorlevel 8 goto next
if errorlevel 7 goto next
if errorlevel 6 goto next
if errorlevel 5 goto next
if errorlevel 4 goto next
if errorlevel 3 goto next
if errorlevel 2 goto next
if errorlevel 1 goto end

:next
if %letter%==a set word=Arts
if %letter%==b set word=Business
if %letter%==c set word=Computers
if %letter%==d set word=Games
if %letter%==e set word=Health
if %letter%==f set word=Home
if %letter%==g set word=Kids
if %letter%==h set word=News
if %letter%==i set word=Recreation
if %letter%==j set word=Reference
if %letter%==k set word=Regional
if %letter%==l set word=Science
if %letter%==m set word=Shopping
if %letter%==n set word=Society
if %letter%==o set word=Sports
if %letter%==p set word=World
if %letter%==q goto end

type c:\cat.txt | findstr /b "%word%" > c:\testing\breakdown.txt

for /f "tokens=*" %%j in ('type c:\testing\breakdown.txt^|find /c
"%word%"') do set line=%%j

set start=0
set max=%line%
for /l %%d in (%start%,1,%max%) do set num=%%d

for /f %%a in ('readin /f=c:\testing\breakdown.txt') do set readin=%%a

set startline=('', '%num%', '
set endline=%readin%', '%word%', '', '', '', '', '', '', '', ''),

echo>>c:\testing\%word%.txt %startline%%endline%

pause
goto mainmenu

:end
quit
#########################################################

I've used Readin.exe but can a pure batch solution do just as good?

Thankx inadvance,

A bold Neil (did have a full head of hair a week ago)

Herbert Kleebauer

unread,
Feb 21, 2005, 6:06:17 AM2/21/05
to
neil.do...@ntlworld.com wrote:
>
> I've decieded to approch this problem another way.
>
> Now the batch file has the whole line but split into two sections
> (could be made into one?). As you will see below, each line needs to
> add a increment number from '0' upto the last line. Then it needs to
> read from a text file (readin.exe) and add each line to the new file
> all at the same time.
>
> So, for example.
>
> ('', '0', 'Business', 'Business', '', '', '', '', ''),
> ('', '1', 'Business/Real_Estate', 'Business', '', '', ''),
> etc...
>

I'm not sure what you want to do. The following batch file:

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>edl.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>edl.com
echo ?@}I{uNWEF~NPGQaEFAKLGSaIj@KMuHaEFGKYGSavh@{HM?cGOuGGwHm?z>>edl.com
echo CgisGGH`LbuuGNO@hRgco{W?dOGg@N?]gBgoG}G?X_SgONks?GN`LBgDu}>>edl.com
echo G?I_DgGNoG?w@jgLiuuroD@?FHoGpBBDcB?1?pIoGxaEGybECt}ExvHmEA>>edl.com
echo AoF?DO~yanxGWap?@?lpZrH~sa`LyNHKqDGwQVTNG`CoECICtdL{D?{esL>>edl.com
echo ysICu_{OuD@sGxECHt~F@rgNHYq`EE{S~{HqegC{Lr@CE{HQ}@ExuGtPmB>>edl.com
echo BwjFCs?osqs?}n`LKLj?o{}HwJvCrpGyECt~~1}HGGHGy`G{}COuJaxLGS>>edl.com
echo i}BWuNC_FE{sGQEGFAPqGSEGNAcQNJwLECuQsa{Oe~CK~GQqGSeGSEFbCT>>edl.com
echo G?QEFbBgGGH1jnjBrz?JAcqo~O~?lJgvxs~CspajF{oFEBHijnjBrz?JAc>>edl.com
echo vx~O~?QJLqos~CspFjN{xFEByijnj@ComJcIpGy@ojZN{mJQujG{{]JQJB>>edl.com
echo GcCrmCJbjbGy]CFrj~GQEGjBSo_KVBxVkSfCA?A_@NJBHmCrnEp1JYjxCo>>edl.com
echo I[r`{BFCHtdC}ECQBsGC@ZgB@WgB}fj~BsMV@NgB~]hvsb{Os{{Q{msDOs>>edl.com
echo ycsk{SK{PQ{TsHVsQdsq{Sj{]ACCNWl{~BXCNW_K~BxVkSfCA?Cb@N}W@{>>edl.com
echo =sIfjBH}G}H}NK}NNguM@[umGWBJWD@mzDGCCrmCJFuhCrmC{@jJSN?`G}>>edl.com
echo EC{Cs@Ptcc?AyAFZp{GQEGjBKpEFDNIGQq=jBktx{SAzDgsjGKtl{SCzDg>>edl.com
echo jjGKtc{SEzDgajGKtG{SGzDgXjGKtL{SIzDgOjGKtR{SKzDgFjGKtX{S?z>>edl.com
echo MgFIGG?KgF@FIE?EgF}ThzoEuRN~CK}xDqgLoqo?t_ogIK?h?{JU=fGMuG>>edl.com
echo Ouz_FrGCsCyOjEEsjwr~EvPK~GypCt~Fy}HQ}HGGxG{pERNG]GxPa_BfsG>>edl.com
echo UaUy?h@xGGJH?w``LRaDBBobc?W?a_W?G_0x>>edl.com

:: usage: edl "string1" "string2" <infile >outfile
:: replaces any non empty line in infile by string2
:: (a line is non empty if it contains at least one
:: character greater 0x20) and writes it to outfile.
::
:: Any character in string1 separates words
::
:: string2 can contain:
:: $00-$ff : hexbytes
:: $:abcd : input line [ab:cd] ab,cd hex values
:: $#0 : complete input line
:: $#n (n=1..9) : 1.- 9. word of input line
:: $#c (c=a..z) : 10.-35. word of input line
:: $l : line till first separator char
:: $L : line till last separator char
:: $r : line after first separator char
:: $R : line after last separator char
:: $+ : increment number before $+
:: $- : decrement number before $-
:: $tY : year (upper 2 digits)
:: $ty : year (lower 2 digits)
:: $tm : month
:: $td : day
:: $tH : hour
:: $tM : minute
:: $tS : second
::
:: instead of $ you can also use @, then any % is doubled

edl "/" "('', '0000$+', '$#0', '$#1', '', '', '', '', ''),"<infile>breakdown.txt
del edl.com
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

will generate from this input file (input)



> Business
> Business/Real_Estate
> Business/Real_Estate/Legal
> Business/Real_Estate/Legal/Title_Services
> Business/Real_Estate/Legal/Title_Services/Title_Insurance
> Business/Real_Estate/Legal/Title_Services/Title_and_Escrow
> Business/Real_Estate/Legal/Surveyors
> Business/Real_Estate/Employment
> Business/Real_Estate/Employment/Job_Search
> Business/Real_Estate/Employment/Executive_Search
> Business/Real_Estate/Employment/Individual_Resumes
> Business/Real_Estate/Commercial
> Business/Real_Estate/Commercial/Associations
> Business/Real_Estate/Commercial/Marketing_and_Advertising
> Business/Real_Estate/Commercial/On-Line_Listing_Services
> Business/Real_Estate/Commercial/Lenders
> Business/Real_Estate/Commercial/Consulting
> Business/Real_Estate/Commercial/Economic_Development_Agencies
> Business/Real_Estate/Commercial/Business_Brokers
> Business/Real_Estate/Commercial/Business_Brokers/National_Companies

the output file (breakdown.txt):

('', '0000', 'Business', 'Business', '', '', '', '', ''),
('', '0001', 'Business/Real_Estate', 'Business', '', '', '', '', ''),
('', '0002', 'Business/Real_Estate/Legal', 'Business', '', '', '', '', ''),
('', '0003', 'Business/Real_Estate/Legal/Title_Services', 'Business', '', '', '', '', ''),
('', '0004', 'Business/Real_Estate/Legal/Title_Services/Title_Insurance', 'Business', '', '', '', '', ''),
('', '0005', 'Business/Real_Estate/Legal/Title_Services/Title_and_Escrow', 'Business', '', '', '', '', ''),
('', '0006', 'Business/Real_Estate/Legal/Surveyors', 'Business', '', '', '', '', ''),
('', '0007', 'Business/Real_Estate/Employment', 'Business', '', '', '', '', ''),
('', '0008', 'Business/Real_Estate/Employment/Job_Search', 'Business', '', '', '', '', ''),
('', '0009', 'Business/Real_Estate/Employment/Executive_Search', 'Business', '', '', '', '', ''),
('', '0010', 'Business/Real_Estate/Employment/Individual_Resumes', 'Business', '', '', '', '', ''),
('', '0011', 'Business/Real_Estate/Commercial', 'Business', '', '', '', '', ''),
('', '0012', 'Business/Real_Estate/Commercial/Associations', 'Business', '', '', '', '', ''),
('', '0013', 'Business/Real_Estate/Commercial/Marketing_and_Advertising', 'Business', '', '', '', '', ''),
('', '0014', 'Business/Real_Estate/Commercial/On-Line_Listing_Services', 'Business', '', '', '', '', ''),
('', '0015', 'Business/Real_Estate/Commercial/Lenders', 'Business', '', '', '', '', ''),
('', '0016', 'Business/Real_Estate/Commercial/Consulting', 'Business', '', '', '', '', ''),
('', '0017', 'Business/Real_Estate/Commercial/Economic_Development_Agencies', 'Business', '', '', '', '', ''),
('', '0018', 'Business/Real_Estate/Commercial/Business_Brokers', 'Business', '', '', '', '', ''),
('', '0019', 'Business/Real_Estate/Commercial/Business_Brokers/National_Companies', 'Business', '', '', '', '', ''),

0 new messages