Copy a File to current login in users desktop Mac

1.4k views Asked by At

I need a command or something that will allow me to send a file to the current logged in Mac user without manually setting this file location up. Can this be done? Example I have a file called test.app I want to copy this to the users desktop. I don't know what the current users name is and I want it to be pickup automatically and then copy the file down to the user.

2

There are 2 answers

1
Siebe On

Just use ~/Desktop/test.app as the file location. It will put it on the desktop of the current user.

0
SchoolDev On

To find out the all the users, use:

do shell script "cd /Users; ls"
return result

This should return the users in the "Result" tab in the Event Log at the bottom of the AppleScript Editor.

Then to copy test.app, use this:

do shell script "cp -R /path/to/test.app /Users/whateveruser/Desktop/test.app"

And that should copy the file to whatever users desktop you want.

Hope this helps!