1

As a follow up for my previous question (Set the Working Folder of .app Created by Apple Script) I have the following problem.

I have an AppleScript which is Poor man's Installer:

tell me to activate

set appPath to POSIX path of (path to me as text)

set folderName to "'MyFolderName'"

set copyFolder to "cp -r " & appPath & folderName & "'/.' '/Library/Application Support/'" & folderName & "'/' & "

set exitScript to "exit 0;"

display dialog "Run Installer?" buttons {"Run", "Cancel"} default button 1

if the button returned of the result is "Run" then
    do shell script copyFolder & exitScript with administrator privileges

    display dialog "Finished Successfully!" buttons {"OK"} default button 1

end if

So the script above is compiled into Installer.app.
Inside it I put the folder MyFolderName which contains all the sources.

I create a a DMG with the title (Also the Path) My Project.
I run Install.app from the installer and it doesn't work.
I run the Installer.app from Desktop (Or any other place on HD) and it works.

I also changed the DMG title to have no spaces MyProject and it works.

So something in the parsing of appPath into the Script doesn't work if it contains spaces.

Any idea?

1

As I mentioned in my answer to your other question:

Note that when using this in a do shell script command, use quoted form of to allow for spaces in the path filename.

Otherwise you'd need to escape spaces with a backslash \, and that can get messy.


Example: quoted form of appPath

You might want to do the concatenation separately and then pass it to the command.

  • So I need to do: set myPath to quoted form of POSIX path of (path to me as text)? – Royi May 1 at 19:15
  • 1
    @Royi, You can use quoted form of in may different ways, and yes set appPath to quoted form of POSIX path of (path to me as text) or as shown in the example of my answer quoted form of appPath. – user3439894 May 2 at 14:07
  • OK, I will give it a try and report. Thank you for your assistance. – Royi May 2 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .