# zipping a file by command line

**URL:** <https://forum.xojo.com/t/zipping-a-file-by-command-line/48174>\
**Category:** macOS\
**Created:** [April 16, 2019, 6:11am UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174 "2019-04-16T06:11:26Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [April 16, 2019, 5:25pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/21 "2019-04-16T17:25:07Z")

</div>

I come across a very strange behavior here with Xojo. I have inserted comments in the relevant places! Replace the code in PushButton1.Action in my [project](https://www.dropbox.com/s/dpc5081xb7v3aql/Zip%20Files.xojo_binary_project?dl=0) from above with the following:

[code]#If TargetMacOS Or TargetLinux

Dim dialog As New SaveAsDialog  
Dim output As FolderItem = dialog.ShowModalWithin(Self)

If output \<\> Nil Then

```
TempFolder = SpecialFolder.Desktop.Child("foo")
TempFolder.CreateAsFolder

CreateTempFolder(TempFolder)

Dim command, inputPath, outputPath As String

inputPath = """" + TempFolder.NativePath + """"
outputPath = """" + output.NativePath + """"

' This doesn't work correctly. The extra folder "Users/..." will be included.
' command = "cd " + inputPath + "; zip -r -q " + outputPath + " " + inputPath + " *"

' This works correctly, but with a weird command string.
' You can also see it on the Xojo Syntax highlightning.
command = "cd """ + TempFolder.NativePath + """; zip -r -q """ +_ 
  output.NativePath + """ "" + TempFolder.NativePath + "" *"

Shell1.Execute(command)

```

End If

#EndIf[/code]

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 16, 2019, 6:47pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/22 "2019-04-16T18:47:18Z")

</div>

Are-you sure about the number of quotes ?

` inputPath = """" + TempFolder.NativePath + """"
    outputPath = """" + output.NativePath + """"`

4 quotes means 2 quotes (an empty string.

Later, 3 quotes + 1 space + 2 quotes ???

This does not makes sense to me.

Of course, I may be wrong.

---

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [April 16, 2019, 7:43pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/23 "2019-04-16T19:43:58Z")

</div>

@Emile Schwarz Did you tried my code? If you wanna add quotes into a string, you need to uses a double quote to get one quote.  
I modified the command string and now it works fine:

```auto
command = "cd " + inputPath + "; zip -r -q " + outputPath + " *"
```

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_jones/32/8627_2.png) [@Tim\_Jones](https://forum.xojo.com/u/Tim_Jones)\
**Post date:** [April 16, 2019, 8:39pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/24 "2019-04-16T20:39:06Z")

</div>

[quote=432888:@Martin Trippensee]@Emile Schwarz Did you tried my code? If you wanna add quotes into a string, you need to uses a double quote to get one quote.  
I modified the command string and now it works fine:

```auto
command = "cd " + inputPath + "; zip -r -q " + outputPath + " *"
```

I just got back to my desk and was going to send that. Good discovery.

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 17, 2019, 8:59am UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/25 "2019-04-17T08:59:58Z")

</div>

> [@432888:@Martin Trippensee](#):
>
> you need to uses a double quote

Yes, I know, but four quotes ?

---

<div class="post-metadata">

**Author:** ![Stéphane\_Mons](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@Stéphane\_Mons](https://forum.xojo.com/u/St%C3%A9phane_Mons)\
**Post date:** [April 17, 2019, 9:08am UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/26 "2019-04-17T09:08:56Z")

</div>

@Emile Schwarz  It’s weird, I know:

1. The first quote opens the string
2. The 2 quotes inside mean one quote only (i.e. Chr(34))
3. The last quote ends the string literal

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [April 17, 2019, 9:19am UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/27 "2019-04-17T09:19:23Z")

</div>

☹

---

<div class="post-metadata">

**Author:** ![Tim\_Jones](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_jones/32/8627_2.png) [@Tim\_Jones](https://forum.xojo.com/u/Tim_Jones)\
**Post date:** [April 17, 2019, 4:30pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/28 "2019-04-17T16:30:57Z")

</div>

You could also use ChrB(34), but most of us find the “” mechanism more legible (once we know how it works).

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 7:37pm UTC](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174/29 "2020-10-29T19:37:22Z")

</div>



[Previous page](https://forum.xojo.com/t/zipping-a-file-by-command-line/48174.md?page=1)
