Page 1 of 1 1
Topic Options
#139825 - 2005-05-17 11:20 AM Need guidance: Multiple Dir and files to one output file
viking Offline
Fresh Scripter

Registered: 2005-05-06
Posts: 12
Hello,
could you please give me guidance on the following. In a directory "C:\INPUT" I have multiple other directories which includes also multiple files. If the files have a name equal "domains" or "urls" I would like to write the contents of these files to one output file "LOCALDB". Below I did some coding, but I'm not sure if this is the right way to do this (with all the OPENS,filehandles, CLOSE, readlines and writelenes). Thnaks for help.
Bjoern

Code:
 
$HandleOutput = FreeFileHandle ()
$RC = Open($HandleOutput, "C:\LOCALDB",1+4) ; Open Output File

CD "C:\INPUT"

For $I4 = 0 to Ubound($WorkArray)

CD $WorkArray[$I4]

$AktivDir=Dir($WorkArray[$I4])

While $AktivDir <> "" And @ERROR = 0

If ($AktivDir = "domains") Or ($AktivDir = "urls")

$Handle = FreeFileHandle ()
$RC = Open($Handle, "C:\INPUT\"+$WorkArray[$I4]+$AktivDir, 2)

While Not (-1)

$Line = ReadLine($Handle)
$RC = WriteLine($HandleOutput, $Line+@CRLF)

Loop

EndIf

$AktivDir = Dir()
Loop

CD "\"

Close($Handle)

Next

Close($HandleOutput)



Top
#139826 - 2005-05-17 02:13 PM Re: Need guidance: Multiple Dir and files to one output file
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
a simple shell TYPE command would do what you want...

Code:

shell '%comspec% /c type C:\INPUT\' +$WorkArray[$I4]+$AktivDir + " >> C:\LOCALDB"


Top
#139827 - 2005-05-17 02:38 PM Re: Need guidance: Multiple Dir and files to one output file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You can also COPY them all into one file.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#139828 - 2005-05-17 04:50 PM Re: Need guidance: Multiple Dir and files to one output file
viking Offline
Fresh Scripter

Registered: 2005-05-06
Posts: 12
Hi,
thanks a lot for the fast feedback and help.
Still wondering if it would be possible to do such stuff with the OPEN, CLOSE, ReadLine and WriteLine commands.
Bjoern

Top
#139829 - 2005-05-17 05:56 PM Re: Need guidance: Multiple Dir and files to one output file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Yes.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.053 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org