Thanks for the reply. I ended up using getfilesize() to only look at files that are 0-1KB in size.

Everything is working in my script now, but it's taking longer to run that it should. I have three different types of files that I need to run this script on so I have three "For Each" sections that are almost the same except for the $file (filename) variable and the INSTR search string. I put the "For Each" sections back to back. I thought I had to put a Next after each section, but give me an error when I do that. The script works fine other than it loops through each file in the array every time it performs the action on one file. It takes a couple minutes to run the script below, but if I comment out all but one "For Each" section it only takes a couple seconds. I'm sure I'm just missing something easy.

Here's my code:
 Code:
DIM $site $dir $file

$dir = "\\server\data\"
$site = "site1","site2","site3"

For Each $element In $site
$billingfile = $dir + $element + " " + "billing report" + ".csv"
	$sizebill = GetFileSize($billingfile)
	If ($sizebill > "0") and ($sizebill <= "1024")
		? "$billingfile size is $sizebill"
		Open(3, $billingfile) = 0
		$x1 = ReadLine(3)
	? "Line read: [" + $x1 + "]"
	Close (3)
	If InSTR($x1, "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||")
		? "$billingfile file is empty and will be deleted"
		DEL $billingfile
	;? @SERROR
		Else
	? "$billingfile file is not empty"
	EndIf

For Each $element In $site
$glfile = $dir + $element + " " + "ledger report" + ".csv"
	$sizegl = GetFileSize($glfile)
	If ($sizegl > "0") and ($sizegl <= "1024")
		? "$glfile size is $sizegl"
		Open(3, $glfile) = 0
		$x2 = ReadLine(3)
	? "Line read: [" + $x2 + "]"
	Close (3)
	If InSTR($x2, "|||||||||1")
		? "$glfile file is empty and will be deleted"
		DEL $glfile
	;? @SERROR
		Else
	? "$glfile file is not empty"
	EndIf
	

For Each $element In $site
$dxfile = $dir + $element + " " + "dx report" + ".csv"
	$sizedx = GetFileSize($dxfile)
	If ($sizedx > "0") and ($sizedx <= "1024")
		? "$dxfile size is $sizedx"
		Open(3, $dxfile) = 0
		$x3 = ReadLine(3)
	? "Line read: [" + $x3 + "]"
	Close (3)
	If InSTR($x3, "||||||1")
		? "$dxfile file is empty and will be deleted"
		DEL $dxfile
	;? @SERROR
		Else
	? "$dxfile file is not empty"
	EndIf		


So, my question is, how to I get each section to finish before the next one starts? Thanks.


Edited by booey (2007-03-22 06:03 PM)