Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
i have a php script that is supposed to check for duplicate values in a txt/delimited file.
I run the script from console (i have the php.exe and php.dll file in the windows dir).
What i would like to to if possible, is that instead of specifying what file i want to check in the script (tmp.txt), i would like the script to take any file of the format csv, sdv, skv or txt. So, if i paste 10 files in the same dir of the script, it should work on all files 1 after 1. If any errors, it should output the values to "Filename"-Error-Log.xls.
Hope anyone can help.Copy of source code:
<?
$myFile = "Error-Log.xls";
$fh = fopen($myFile, 'w') or die("can't open file");$a = file("tmp.txt");
for ($b=0; $b<count($a); $b++)
{
$a[$b] = (int)$a[$b];
}
sort($a);
$old='novalue';
for ($b=0; $b<count($a); $b++)
{
if ($a[$b]===$old)
{
fwrite($fh, "Duplicate value ".$a[$b]."\n");}
$old=$a[$b];
}
fclose($fh);
?>

Ok, i made a workaround running the php script withing a batch script..
But if its possible, i still would like to know:]

I usually prefer vbscript for windows based scripts since it is handled natively and has some good file structure controls.
However, there is a PHP script on this page on how to return the contents of a directory as an array (which would be the first step): http://us3.php.net/dir
The script is at the very bottom of the page
Michael J

The following page has an example script (that you can download) which recurses through the C drive and creates a report of all .bat files. You could easily modify it to look only in a certain directory (and subdirectories if you wish) for mutiple file extensions.
Michael J

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |