You take linksid.txt and turn it back to 0 or whatever. Then the script would go put the db in an array, and then foreach line of the array(splitting the lines of course by links fields) change the ID's with the incremental $count++ or something like that and then print it back to the linksid.txt. I imagine this would be a really long process. This would make it so if you have lets say 10 links and they go
1, 3, 9, 7, 4, 82, 128, 345, 34, 23
lets say they got unorganized by deleting and modifying and a bad kept linksid.txt. It would go through and change them to 1-10
But of course, if you have link owners, this would be bad if you use a modify.cgi security thing that goes by ID, because their ID will change. If you use the newer mods like Paul's, this would work.