Using Applescript to reference target's desktop

Discussion in 'Mac Programming' started by CountrySeacow, Dec 7, 2012.

  1. macrumors newbie

    Joined:
    Dec 7, 2012
    Messages:
    8
    #1
    Hello,
    I am moderately new to applescript editor.
    I have written code to copy a file from (for safety purposes named-) "DISK1". "DISK1" is a USB disk drive. A file, named "APPNAME.app", when the applescript is run, is supposed to be copied to the users desktop.
    I know how to specify for one user, but I want to be able to run this script on any computer, and for it to still work without having to modify the script before running it.
    My code is as follows:

    Code:
    tell app "Finder"
    	activate
    	set x to file "APPNAME.app" of folder "FOLDER2" of folder "FOLDER1" of disk "DISK1"
    	set y to folder "Desktop" of folder "USERNAME" of folder "Users" of startup disk
    	copy x to y
    end tell
    
    Any help would be useful, and i apologize if this topic is anywhere else on the forums.

    Thanks!
    CountrySeacow
     
  2. Moderator

    robbieduncan

    Staff Member

    Joined:
    Jul 24, 2002
    Messages:
    24,480
    Location:
    London
  3. macrumors newbie

    Joined:
    Dec 7, 2012
    Messages:
    8
    #3
    Okay, well i think the might normally work, but how to i put that into this script?
    (in line;
    if exists file "Macintosh HD:Users:USERNAME:Desktop Minecraft.app" then
    )

    Code:
    tell application "Finder"
    	activate
    	if exists file "Macintosh HD:Users:USERNAME:Desktop Minecraft.app" then
    		display dialog "it exists"
    	else
    		tell application "Finder" to move entire contents of folder "app" of folder "Minecraft_Mac" of disk "MINECRAFT" to folder "Desktop" of folder "USERNAME" of folder "Users" of startup disk
    	end if
    end tell
    
     

Share This Page