Skip to main content
Solved

Deleting Printer

  • October 25, 2016
  • 28 replies
  • 346 views

Show first post

28 replies

scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • August 25, 2021

Precisely that!


I can't tell you how long I've looked for a way to do that!  Cheers, sir! 


Forum|alt.badge.img+5
  • Contributor
  • August 31, 2022

If you go back to a Mac where your script failed on, and run:

lpstat -p | awk '{print $2}'

That will give you a list of all the CUPS printer names on the Mac. You can then compare to your script. I'm almost certain you will find differences in the names.


Hi, the script is giving me this error:

 

Script result: Deleting Printer: Xerox_C60
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.
Deleting Printer: Xerox_C60 lpadmin: The printer or class does not exist.

 

Anyway the name is correct... any tips?


Forum|alt.badge.img
  • New Contributor
  • February 5, 2023

Removing all printers from a Mac before adding new ones can be done with this script.

#!/bin/bash

lpstat -p | awk '{print $2}' | while read printer
do
echo "Deleting Printer:" $printer
lpadmin -x $printer
done

This script has broken the printer setting pane. 

Now I can't see any new printer after adding it.
I tried to right-click and reset printer settings or to reset the system preferences completely and nothing helped.
Please help me