I am trying to write a script to change my default printers. Instead of going into system prefs to change a default printer. I put this script together from examples on the form. It changes the default printer in system prefs and it also renames the script to the name of the printer. The script alternates between the two printer that I have. The script also changes the name on the file on the dock which is handy to see what printer is current. My problem is the script works great while it is on the desktop, but it gives me an error (Can’t set file) when the script is moved into my scripts folder. I’m sure this is something simple but I am not experienced enough to figure it out.
Any help would be appreciated .
Thanks
tell application "Printer Setup Utility"
activate
set myPrinters to every printer
set DefaultPrinter to current printer
if item 1 of myPrinters is DefaultPrinter then
set current printer to item 2 of myPrinters
tell application "System Events"
set PrinterName to name of item 2 of myPrinters
say PrinterName as string
end tell
else
set current printer to item 1 of myPrinters
tell application "System Events"
set PrinterName to name of item 1 of myPrinters
say PrinterName as string
end tell
end if
end tell
tell application "Finder"
set Oldname to name of current application
if Oldname is not equal to PrinterName then
set fileName to PrinterName & ".app"
set name of file Oldname to fileName as string
end if
end tell
quit
Model: Mac Pro
AppleScript: 2.4.3
Browser: Safari 536.26.17
Operating System: Mac OS X (10.8)