AppleScript file copy problem

Discussion in 'Mac Programming' started by doobs, Nov 4, 2008.

  1. doobs macrumors regular

    Joined:
    Jul 19, 2008
    #1
    I am trying to write an AppleScript using Automator that takes as input a file and copies that file to a certain location. The input variable called "input" is in the format "Mac HD:Users:myname:folder:file.txt" and this is causing me problems. The location I am copying to requires admin privileges, so I am executing:

    do shell script "/bin/cp " & input & " /System/Library/CoreServices/file.txt" with administrator privileges

    This variable "input" is not in the correct pathname format and I cannot figure out how to fix this. Also, I tried another approach using:

    tell application "Finder"
    copy file input to "/System/Library/CoreServices/file.txt"

    However, Automator complains when I compile this last script that access is not allowed (and also doesn't like having "with administrator privileges" at the end). Any suggestion? Thanks in advance...
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You need to convert it with "quoted form of POSIX path of input"
     

Share This Page