I’m trying to write a XojoScript for MacOS to
- Make a new directory alongside the project file
- Copy the project file into it
The first steps are to get the path to the project folder and set the working directory to the project folder, but I can’t get that to work.
Var ProjFilePath As String = ProjectShellPath // Path to the Xojo project file
Dim Dirs() As String = ProjFilePath.split("/")
Dirs.RemoveAt(Dirs.LastRowIndex) // Remove the project file from the path
Dim ProjectFolderPath As String = String.FromArray(Dirs,"/") + "/"
Var command As String
Var result As String
Print "Project folder path is "+projectfolderpath // This shows the correct path to the project folder
command = "cd "+ ProjectFolderPath
result = DoShellCommand(command)
If result <> "" Then Print "cd "+result // cd reports no error
result = DoShellCommand("pwd -P")
Print "Current working Directory is: "+Result // This shows "/" instead of the expected result of cd
When I manually do the same steps using Terminal, cd changes the working directory to the project folder and pwd shows that it worked; then I can do mkdir. Using the script, cd seems to have no effect - the working dir remains “/”.