shell.NativePath and shell.ShellPath

Hi,
there may be cases when a shell path gets a little tricky.
For instance, I have three .epub file (File1.epub, File2.epub, File3.epub) created from the same source by the same app (Pages) using the same settings, and they are located in different locations.
The first file was created on Oct 8 2019, while the other two on Dec 18 2019. At that time my MBP was running HighSierra.
Moreover, they have the same read/write permissions (in Finder > Info).

Now, running the ‘Old code’ below, the shell would create the “OPS” folder and its content only for the first file.
For the other two files, the shell would give different reasons, form folder not found, to write permission not available and so on.
Only when I changed from s.Execute "cd " + mparent + " ; unzip " + f.NativePath
to
s.Execute "cd " + mparent + " ; unzip " + f.ShellPath
I got the expected results.

So, although I solved the problem (cfr New code, below), I’m curious to know, if possible, the reason for such behavior.
Thanks.

Old code:

dim temp as folderitem = specialfolder.desktop.child("my folder")//I leave out the usual nil/exists checking dim s as new Shell dim mparent as string = """" + temp.NativePath + """"//using shellpath mparent will not be gotten in s.exexute s.Execute "cd " + mparent + " ; unzip " + f.NativePath while s.IsRunning Wend dim ops as FolderItem = temp.Child("OPS")//this folder should be available in all .epub files dim source() as String if ops <> nil and ops.Exists then

New code:

dim s as new Shell dim mparent as string = """" + temp.NativePath + """"//do not use shellpath s.Execute "cd " + mparent + " ; unzip " + f.ShellPath while s.IsRunning Wend if s.ErrorCode <> 0 then dim ss as new Shell ss.Execute "cd " + mparent + " ; unzip " + f.NativePath while ss.IsRunning Wend end if dim ops as FolderItem = temp.Child("OPS")//this folder should be available in all .epub files dim source() as String if ops <> nil and ops.Exists then

For the shell you always need shellpath. The difference is in escaping characters like " " to "\ ". Drag a file with spaces to the Terminal and you will see what I mean.

Native path needs to be used with " before and after (and maybe some escape)
Shell path needs to be escaped (more cases than only the spaces)

with this in mind you can use native path in shell commands

@Beatrix Willius: [quote]For the shell you always need shellpath.[/quote]
Actually I have always being using shellPath.
The mess happened when I googled for unzip and got an answer showing the destination folder surrounded by “”.
So when I tested it in a shell, I wrote:
dim mparent as string = “”"" + temp.ShellPath + “”""

When it did not work, I tried using NativePath, and since it worked I even put a reminder NOT to use shellPath:

dim mparent as string = “”"" + temp.NativePath + “”""//using shellpath mparent will not be gotten

@Antonio Rinaldi: [quote]Native path needs to be used with…[/quote]

In fact removing the “” everything works all right:
s.Execute "cd " + temp.ShellPath + " ; unzip " + f.ShellPath

Thank you very much.

If you don’t want to worry about Quoting the path, use .ShellPath. In your example, you could use:

s.Execute "cd " + temp.ShellPath + " ; unzip " + f.ShellPath
or

s.Execute "cd """ + temp.NativePath + """ ; unzip """ + f.NativePath + """"
Either would give you the same result.

The key is to not mix them and then get paths that don’t make sense.

Yes, that’s what I did after understanding the issue. In fact I was mixing shellpath and nativepath.
Thanks.