Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to Duplicate Files without Finder?

Hi!

I have an app I made in Xcode that takes a PNG image that the user chooses and makes it the Finder, Empty Trash, or Full Trash icon. It works well, but there is one thing that bugs me. Because it is making a system change, it requires a password. But the window says "Finder wants to make changes. Type your password to allow this." but I want it to use my app's name and icon. How can I change the script so that the app duplicates, not Finder?

Also, here is my current script:

on EmptyTrashButtonPushed_(sender)

set EmptyTrashIcon to (choose file with prompt "Choose a PNG icon to use for your Empty Trash icon:" of type {"PNG"} without invisibles)

tellapplication"Finder"

set theDupe to (duplicate EmptyTrashIcon) as alias

set the name of theDupe to "trashempty.png"

move theDupe to"Macintosh HD:System:Library:CoreServices:Dock.app:Contents:Resources:"with replacing

end tell

do shell script "killall Dock"

end EmptyTrashButtonPushed_


I want it to duplicate the original file so that the user's file stays untouched.

Thank you very much

MacBook Pro, OS X Mountain Lion (10.8.2)

Posted on Jan 25, 2013 3:01 PM

Reply
Question marked as Best reply

Posted on Jan 25, 2013 7:16 PM

The dialog says the Finder wants to make the change because that is who you are asking to make the change. You could use a do shell script command instead of the Finder statements - for example, the following makes a copy directly to the destination:


do shell script "cp " & (quoted form of POSIX path of EmptyTrashIcon) & space & "/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png" with administrator privileges

3 replies
Question marked as Best reply

Jan 25, 2013 7:16 PM in response to MacOSXNoob

The dialog says the Finder wants to make the change because that is who you are asking to make the change. You could use a do shell script command instead of the Finder statements - for example, the following makes a copy directly to the destination:


do shell script "cp " & (quoted form of POSIX path of EmptyTrashIcon) & space & "/System/Library/CoreServices/Dock.app/Contents/Resources/trashempty.png" with administrator privileges

Applescript to Duplicate Files without Finder?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.