Page 1 of 1 1
Topic Options
#212416 - 2017-04-08 03:13 AM Count folders and read a file...
Singh Offline
Just in Town

Registered: 2017-04-08
Posts: 1
Loc: West Midlands
Hi All

this is my first post for help...

Here is the situation.
I have mutliple folders... from 000000 and counting up in increments of 1 (000001,000002 etc)

In each folder i have a text file that is the same name and format and I need to read line 10 from each folder and put all the results into a single output file

IE.
I have a folder called D:\OUTPUTS
In that I have all these counting up folders (000000,000001 etc)
Find entry in line 10 in file info.txt in each folder. (but trim the first 3 chars off the file
and output those all to a single txt/csv in the root of d:\outputsinfo.txt


Can anyone please help to assist in the counting...

I have this so far...

works for one file... nothing to count each folder up

 Code:
Break On
$folder = "000000"
$ffh = FreeFileHandle()
If Open($ffh, "d:\Outputs\" + $folder + "\info.txt") = 0
	$line = ReadLine($ffh)
	While @ERROR = 0
		$count = $count + 1
		If $count = 11
			$trimmed = Right($line, Len($line) - 3)
			? $trimmed
		EndIf
		$line = ReadLine($ffh)
	Loop
	$RC = Close($ffh)
EndIf

Top
#212417 - 2017-04-08 06:32 AM Re: Count folders and read a file... [Re: Singh]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Here is something you can work on. *Untested*, and I might have done it a different way if I had more details.

 Code:
Break On

$ffh = FreeFileHandle()
if open($FFH,"D:\outputsinfo.txt",5)=0
  for $i=0 to 1000
    $folder = right("000000" + $i,6)
    $ffh2 = FreeFileHandle()
    If Open($ffh2, "d:\Outputs\" + $folder + "\info.txt") = 0
      $line = ReadLine($ffh2)
      $count=0
      While @ERROR = 0
	$count = $count + 1
	If $count = 11
          $trimmed = Right($line,-3)
          ? $trimmed
	  $RC=Writeline($FFH,$trimmed)
	EndIf
        $line = ReadLine($ffh2)
      Loop
      $RC = Close($ffh2)
    EndIf
  next
  $RC=close($FFH)
endif

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
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.048 seconds in which 0.021 seconds were spent on a total of 13 queries. Zlib compression enabled.

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