0

This straightforward approach doesn't seem to work:

In[42]:= cmd = StringSplit@"zip -r ~/data.zip ~/test/*"
In[43]:= RunProcess@cmd

enter image description here

Related: How can I encrypt/decrypt a directory?

M.R.
  • 31,425
  • 8
  • 90
  • 281
  • Try the less straightforward approach that doesn't assume zip will do wildcard expansion, which is the job of the shell... this is nothing to do with Mathematica, it seems to me. – Oleksandr R. Jan 18 '16 at 23:35
  • Are you aware of CreateArchive? – C. E. Jan 19 '16 at 00:54
  • But this command works in the terminal @OleksandrR. – M.R. Jan 19 '16 at 00:55
  • @Pickett Forgot that one, yup that solves it. But it would be nice to understand why this command that works in the shell won't work when invoked with RunProcess. If you post this as an answer I'll accept. – M.R. Jan 19 '16 at 00:57
  • @M.R. what do you expect? The purpose of "the terminal" is to run a shell. Try execing zip directly from C and see if it works--I bet it won't. – Oleksandr R. Jan 19 '16 at 01:25
  • Sure, but isn't one purpose of RunProcess to enable you to run a shell process and interact with it? – M.R. Jan 19 '16 at 01:29
  • Ah we are getting to the heart of the issue -> I don't think it replaces a shell, but the shell is a process that RunProcess and friends were made to work with. Am I misunderstanding something? – M.R. Jan 19 '16 at 01:30
  • @M.R. you have nowhere attempted to run a shell. You just call zip directly. I am sure it would work if you used the/a shell to evaluate this command line. – Oleksandr R. Jan 19 '16 at 01:30

1 Answers1

2

Since Mathematica 8.0 we are in luck and there is a command called CreateArchive that can do this for us. Documentation: CreateArchive.

C. E.
  • 70,533
  • 6
  • 140
  • 264