cmd script - two file read and matching...

G

Guwoon

Hi~
I want to make files name from two file.
How can I do that from cmd script?


Example)
o Two file
Type1.txt
---
person1
person2
person3
---

Type2.txt
---
type1
type2
type3
type4
type5
type6
type7
---

o Result
person1type1.txt
person2type2.txt
person3type3.txt
person1type4.txt
person2type5.txt
person3type6.txt
person1type7.txt
 
P

Phil Robyn

Guwoon said:
Hi~
I want to make files name from two file.
How can I do that from cmd script?


Example)
o Two file
Type1.txt
---
person1
person2
person3
---

Type2.txt
---
type1
type2
type3
type4
type5
type6
type7
---

o Result
person1type1.txt
person2type2.txt
person3type3.txt
person1type4.txt
person2type5.txt
person3type6.txt
person1type7.txt

- - - - - - - - - - begin screen capture - - - - - - - - - -
<Win2000> c:\cmd>demo\CombineWithRepeat
person1type1
person2type2
person3type3
person1type4
person2type5
person3type6
person1type7

<Win2000> c:\cmd>rlist demo\CombineWithRepeat.cmd
=====begin c:\cmd\demo\CombineWithRepeat.cmd ====================
01. @echo off
02. setlocal ENABLEDELAYEDEXPANSION
03. set person_ctr=0
04. for /f %%a in (c:\temp\Type1.txt) do (
05. set /a person_ctr+=1
06. set person!person_ctr!=%%a
07. )
08. set /a total_persons = person_ctr
09. set person_ctr=0
10. set line_ctr=0
11. for /f %%a in (c:\temp\Type2.txt) do call :get_lines %%a
12. for /l %%a in (1,1,%line_ctr%) do call echo %%line%%a%%
13. goto :EOF
14. :get_lines
15. set /a line_ctr+=1
16. set /a person_ctr+=1
17. call set line%line_ctr%=%%person%person_ctr%%%%1
18. if %person_ctr% equ %total_persons% set /a person_ctr=0
19. )
=====end c:\cmd\demo\CombineWithRepeat.cmd ====================
- - - - - - - - - - end screen capture - - - - - - - - - -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top