0

I have found alot of examples that focus on compressing full folders but can't find any on how to zip certain files in a folder.

For example: File 1, File 2 and File 3 are in the same folder, i only want to zip files 1 & 2. I have powershell 4.0.0 any advice?

James
  • 21
  • 1
  • 3
  • Create a function that copies file 1 and 2 to a temp directory, create the zip file from that and then remove the temp directory again? – Mathias R. Jessen Sep 20 '16 at 14:52
  • 1
    Please check this thread and this answer: http://stackoverflow.com/a/13302548/5622042 – paul543 Sep 20 '16 at 14:52
  • How are you currently compressing a folder? (NB [`Compress-Archive`](https://technet.microsoft.com/library/dn841358.aspx) accepts files and folders.) – Richard Sep 20 '16 at 14:55
  • @Richard The function you posted is for version 5.0, not 4.0. – rrirower Sep 20 '16 at 14:56
  • Except, the duplicate answers doesn't actually solve/answer OP's question... – Mathias R. Jessen Sep 20 '16 at 15:02
  • @MathiasR.Jessen It does implicitly: you need to use .NET types or an external module (like PSCX) prior to PSH 5. – Richard Sep 20 '16 at 15:12
  • 1
    @MathiasR.Jessen Most of the answers given to the other question can be adopted to compress a single file instead of multiple files with minimal effort. I fail to see how that does not answer the OP's question. – Ansgar Wiechers Sep 20 '16 at 23:44
  • i wasn't aware you were able to use a filter to go through the files i see that now thanks for your responses! – James Oct 04 '16 at 08:58

0 Answers0