AllPlease help me on this.
I want to compare filenames in a directory which sounds easy enough, but what I need to do is this.
Compare filenames BEFORE the extension. If there are two file os the same name, but different extension, then delete both of them. Eg. If there are th efiles name1.csv name1.cnf name2.csv
then the script should delete the files name1.csv and name1.cnf, but leave name2.csv.
I have tried a loop where I get the names of all the files in the dir with the extension CSV and a second list with all the files with extension cnf.
I then loop using readline, by reading the first line of the first file, and comparing to line one of the second file, line two of the second file etc.
The following is a the script I have tried for the compare and loop, but does not appear to work. (The file names in each txt files are the same, so I am checking if the file name1.txt exists in both listings)
The script goes off in an infinite loop even if there are only two files in each list.
AM GOING MAD TRYING TO SORT THIS OUT!!!!!
break on
IF Open (1, dirlist.txt)=0
DO
WHILE @error=0
$y=1
$x=Readline ($y)
"$x "?
If open (2, dirlist2.txt)=0
while @error=0
$a=1
$b=Readline ($a)
If $b=$x
?"$b and $x are the same!!!!!"
else
?"NOTHING"
endif
sleep 1
$a="$a+1"
Loop
Close (2)
Else ?"could not open dirlist2 becasue of error @error"
sleep 5
Endif
$y="$y+1"
Loop
Close (1)
Until $x=0
Else
?"unable to read file"
ENDIF