Not quite. Certainly the Holy Spirit has stepped in, from time to time, to prevent popes from making erroneous declarations regarding doctrine and dogma. But the usual way the Holy Spirit operates is to guide the pope in union with the bishops, called the Magisterium, into all truth, as Jesus promised he would do.
If this is true then what need would there be for a council to determine what is scripture or doctrine and what is not?
Not necessarily. Councils have been held for that reason, but popes can, and have made definitive dogmatic decisions without them.
working though the magisterium, The Holy Spirit as many times prevented bad Popes from destroying doctrine.
And there is one time (though I can’t remember the Pope’s name of the top of my head) which didn’t listen to the magisterium. When he was about to proclaim a faulty Biblical Translation has a dogmatically correct and official translation of the Church, he died the night before he was about to make that mandate on the Church.
There have definitely been bad popes; some even quite evil. It doesn’t take a whole lot of effort to find reliable sources to the fact. There have been instances of a new Pope coming into the office and decrying the evils of a predecessor. None of the evil popes have destroyed doctrine though.
Some were murderers, some were womanizers, some bought and sold graces (and their office); yet, no matter how sinful a pope was, he never sullied doctrine or taught something of error as dogma. The fact that the dogma of the Church has survived these individuals (as well as many of the other notorious Catholics who haven’t been pope) is the very definition of Christ’s promise to St. Peter. The Church teaches Christ was without sin, and that the Blessed Mother was; it never states that St. Peter, St. Linus, St. Cletus (Anacletus), St. John Paul II, Benedict XVI, or Francis would be perfect or without sin during their pontificates. Recall that Peter (being the head of the Church) had to be admonished by St. Paul for preferring the Jewish Christians for company over the Gentile Christians. Galatians 2:11-16
“But even if you believe the Bishop of Rome to be in error, that does not give you the right to judge him, for only God can judge the pope. No mortal man may accuse him of faults. Oh, how wrong is the opinion of many men: though they do not allow a king’s subjects to have any say against the king, they would allow it in the case of the pope even if God has given him power over all mortal men. Those stupid men are unconcerned that the Holy Apostolic Church has, from Saint Peter to this day, never been heard to teach anything that is contrary to orthodox faith. This privilege it has received from the Lord that it shall never succumb to wrong teachings for the gates of hell shall not prevail against it. Let this
suffice concerning your praise of the Apostolic See.”
“2 And all the children of Israel murmured against Moses and Aaron, saying:
3 Would God that we had died in Egypt and would God we may die in this vast wilderness, and that the Lord may not bring us into this land, lest we fall by the sword, and our wives and children be led away captives. Is it not better to return into Egypt?
4 And they said one to another: Let us appoint a captain, and let us return into Egypt.
5 And when Moses and Aaron heard this, they fell down flat upon the ground before the multitude of the children of Israel.
6 But Josue the son of Nun, and Caleb the son of Jephone, who themselves also had viewed the land, rent their garments,
7 And said to all the multitude of the children of Israel: The land which we have gone round is very good:
8 If the Lord be favourable, he will bring us into it, and give us a land flowing with milk and honey.
9 Be not rebellious against the Lord: and fear ye not the people of this land, for we are able to eat them up as bread. All aid is gone from them: the Lord is with us, fear ye not.
10 And when all the multitude cried out, and would have stoned them, the glory of the Lord appeared over the tabernacle of the covenant to all the children of Israel.
11 And the Lord said to Moses: How long will this people detract me? how long will they not believe me for all the signs that I have wrought before them?
12 I will strike them therefore with pestilence, and will consume them: but thee I will make a ruler over a great nation, and a mightier than this is.”