0

I want to compress a folder and its all content through command line. It should be similar to when we compress some folder in windows 7 64 bit. By right click any folder -> send to -> compress folder. Is there an equivalent to above process of compressing using command line. I want it through command line as I want to create an batch file. I can't use any third party tools.

Mandar Pande
  • 12,250
  • 16
  • 45
  • 72
Jash
  • 942
  • 4
  • 17
  • 40
  • Check the answers to [this question](http://stackoverflow.com/q/1153126/1630171). – Ansgar Wiechers Sep 04 '12 at 11:05
  • also, this is with vbscript: http://stackoverflow.com/questions/2888972/write-to-file-using-copyhere-without-using-wscript-sleep check the top answer – SeanC Sep 04 '12 at 20:44

2 Answers2

1

Nativelty? No, but you can use things like 7-Zip which has command line utilities. 7-Zip is free by the way, and does not need to be installed.

http://www.7-zip.org/

Well, I found a few things you could try with PowerShell:

http://blogs.msdn.com/b/daiken/archive/2007/02/12/compress-files-with-windows-powershell-then-package-a-windows-vista-sidebar-gadget.aspx

https://serverfault.com/questions/18872/how-to-zip-unzip-files-in-powershell/201604#201604

This has Command Line and PowerShell solutions :

https://superuser.com/questions/110991/can-you-zip-a-file-from-the-command-prompt-using-only-windows-built-in-capabili

Community
  • 1
  • 1
Delorean
  • 491
  • 4
  • 17
  • Nope its not allowed in my org, can it be done through .NEt ? – Jash Sep 04 '12 at 11:06
  • @Jash Not from the shell and not with no addons – Delorean Sep 04 '12 at 11:08
  • the last link does not require powershell nor 7 zip and is what you are looking for. I implemented it in some scripts but be aware that it is very hard to detect when the compression is finished. – jolivier Sep 04 '12 at 12:40
  • @jolivier I was actually referencing the answer by "Beaner" in the last link which is Powershell but I wasn't really specific, thanks for point it out. – Delorean Sep 04 '12 at 13:44
0

try compact or zip. Compact creates a compressed file while zip is identical to what you are doing folder -> send to -> compress folder