Cryptoc1
Cryptoc1

Reputation: 43

Error Copying a User Chosen Photo With AppleScript

I'm writing on AppleScript to take a photo I choose a put it in /System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Resources, although whenever I run the script it throughs an error, saying

"340:354: execution error: Finder got an error: Can’t set file (alias "Macintosh HD:Users:Samuel:Pictures:4.jpg") to folder "Macintosh HD:System:Library:PrivateFrameworks:LoginUIKit.framework:Versions:A:Frameworks:LoginUICore.framework:Resources". (-10006) (1)"

osascript -e 'set this_file to choose file
display dialog "Login Walls is now going to attempt to change the wallpaper." buttons {"Okay"} default button "Okay"
tell application "Finder"
    set apple to "apple.png"
    copy folder "Macintosh HD:System:Library:PrivateFrameworks:LoginUIKit.framework:Versions:A:Frameworks:LoginUICore.framework:Resources" to file this_file
end tell'

The snippet above is from a .sh that is called from the applet script with Admin Privileges.

What I really need to have be done is that the file be copied and renamed, if one can tell me how to do that.

Upvotes: 1

Views: 76

Answers (1)

regulus6633
regulus6633

Reputation: 19030

A few things... first the Finder does not have a "copy" command. The Finder's dictionary tells us that copy isn't available. It never has been available. Use the "duplicate" command instead. Second, you want to duplicate a file to a folder. In your code you copy a folder to a file which doesn't make sense. Third, this_file is already an alias type file, therefore the word "file" before this_file in the copy command isn't needed. You only need to use the word file or folder when your path is in a string format (as it is for you folder). This is not the case for this_file so remove the word file from the command.

Good luck.

Upvotes: 2

Related Questions