SAD DAY: Steven Baum leaves court in Poughkeepsie yesterday after being called out by the judge.Lee Ferris

Take that, Steven Baum!

The 50-year-old lawyer, who owns New York’s largest home-foreclosure mill, made a rare appearance in a courtroom yesterday — and was promptly ripped by a Bankruptcy Court judge frustrated by his firm’s sloppy work.

Baum, whose eponymous firm has filed more than 25,000 foreclosure actions across the state over the past three years — many of which have been attacked for containing bogus documents — was lectured by Judge Cecilia Morris to correct his way of practicing law.

“How many times do I have to tell you, you didn’t do it right,” Morris said during the afternoon hearing. “Do you not understand ‘do it right’?” she asked Baum.

Morris had ordered Baum to appear in her courtroom personally after a steady stream of his firm’s lawyers mucked up several of the 180 foreclosure cases he has before the New York federal courts.

The judge accused Baum of “slowing down the court” by failing to properly transfer his cases to other lawyers as he prepared to shutter his Buffalo-area firm.

Baum settled a probe by the Manhattan US Attorney last year and then was forced to close down his 90-lawyer practice when Fannie Mae and Freddie Mac refused to have anything to do with the firm.

The New York attorney general is said to be probing Baum as well.

“Please don’t make me angry,” Morris warned.

The hearing in the Poughkeepsie courtroom was attended by several bankruptcy lawyers who have sparred with Baum in the past, who said afterwards that they were there just to see Baum sweat.

The millionaire legal eagle usually directs his statewide operation from the comfort of his Amherst, NY, offices.

Apparently not happy with his responses to questions, Morris ordered Baum to make repeat appearances in her courtroom until “each file” is corrected.

“I’m telling you, you are walking on bad faith,” Morris said.

“I thought it was very clever of the judge,” said Linda Tirelli, a lawyer who has had to deal with Baum’s sloppy foreclosure work as opposing counsel and who attended yesterday’s hearing. “She basically sanctioned him to go and sit in that court and force him to deal with what she has had to deal with every single week.”