compressing (zip) a single file in shell

to zip a single file I use this code:

dim dlg as new OpenDialog dlg.InitialDirectory = SpecialFolder.Desktop dim f as FolderItem = dlg.ShowModalWithin(self) if f <> nil then dim destination as string = f.Parent.Child("").ShellPath dim s as new Shell s.Execute "zip " + destination + " " + f.ShellPath end if

The “” file gets created, but when I double-click it I find the deflated file buried into several nested folders.
For instance, if the original file (“myfile.doc”) is in a folder (“myFolder”) on the desktop, after zipping it and double-clicking the newly created file I get a folder with nested folders in this order:
users > carlorubini > desktop > myFolder > myfile.doc

So, how to zip a single fileso that the zipped archive contains the original file only?
Suggestions welcome. Thank you.

you’ve read the man page for ZIP on macOS ?
I’d start there as it has a LOT of options
probably the -j option is what you need

… or “cd” into the parent folder and THEN get the file(s). By doing what you’re doing, you’re starting at “/”, so you get all of the folders in the hierarchy from root to the selected file.

Thank you, @Norman Palardy and @Tim Jones

@Norman Palardy: Yes, I had read the man page, but I was not sure which option I had to start with; and since I fear tinkering with Terminal I opted asking the forum.
-j fixed it.

@Tim Jones: I had tried also “cd” but I was getting the same “nested” results; obviously I was messing things, as usual.