Hi-
I have been trying to get the following script to take the selected jpg and use it to replace the default Login pic. As it is now, for some reason I keep getting an error (cp: Macintosh:Users:Frank:Desktop:apple splat green.jpg: No such file or directory) that basically the file was not found to use as the replacement. Could someone please help me understand what I am missing?
Thanks-
Frank
tell application "Finder"
set theSelection to (selection as string)
end tell
set AppleScript's text item delimiters to {"."}
set imgCheck to last text item of theSelection
if imgCheck = "jpg" then
do shell script ("cp " & quoted form of theSelection & " /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
else
do shell script ("sips -s format jpeg " & quoted form of theSelection & " --out /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
end if
display dialog "The login desktop backgound has been changed." buttons {"OK"} default button 1 with icon 1
Hi,
.quoted form of POSIX path of theSelection.
in both lines
Thanks StefanK!
How would you make something like this have the ability to drag onto it to perform the script?
on open theseItems
set thisItem to item 1 of theseItems
if name extension of (info for thisItem) is "jpg" then
do shell script ("cp " & quoted form of POSIX path of thisItem & " /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
else
do shell script ("sips -s format jpeg " & quoted form of POSIX path of thisItem & " --out /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
end if
display dialog "The login desktop backgound has been changed." buttons {"OK"} default button 1 with icon 1
end open
Is it possible to have it open both ways?
on run
tell application "Finder" to set sel to selection
if sel is not {} then open sel
end run
on open theseItems
set thisItem to item 1 of theseItems as alias
if name extension of (info for thisItem) is "jpg" then
do shell script ("cp " & quoted form of theSelection & " /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
else
do shell script ("sips -s format jpeg " & quoted form of theSelection & " --out /System/Library/CoreServices/DefaultDesktop.jpg") with administrator privileges
end if
display dialog "The login desktop backgound has been changed." buttons {"OK"} default button 1 with icon 1
end open
Thank you very much for your help and speed!