0

I have a Windows Server 2008R2 which has a massive file share of Video files, I need to run a zip command line in a batch script which will :

a) Compress / zip each video file inside each folder with the respective filename
b) then compress / zip each folder with its respective name
c) Retain the original folder structure
d) then zip the whole structure into one single zip file containing the whole folder structure and video zip files inside it.

is this even possible ? Can I use any of the above programs via command line to batch / powershell it ?

The server has 8GB RAM with a Core i3 Processor.

Will be grateful for your suggestions and help

user9517
  • 114,104
  • 20
  • 206
  • 289
Mutahir
  • 2,347
  • 2
  • 32
  • 42
  • 2
    Why not zip everything at once? – 84104 Jul 07 '11 at 21:00
  • 3
    I'm with user84104. Doesn't zipping up the parent folder achieve the same thing? Zipping each file, and then each child folder, and then the parent folder seems like a bit of errant logic to me. Zipping them in this manner isn't likely to achieve any more compression than zipping up the parent folder in a single operation. – joeqwerty Jul 07 '11 at 21:05
  • 1
    Have you tried zipping a few files to test? Most common video formats these says are already highly compressed. It seems likely are are not going to see any significant gains in storage usage. Maybe you should simply be using a win32 port of [tar](http://linux.die.net/man/1/tar). – Zoredache Jul 07 '11 at 21:22
  • BTW what you are asking for is certainly possible. – Zoredache Jul 07 '11 at 21:25
  • 5
    Compressing a file and then compressing the folder will result in a larger archive file than doing either one or the other alone, not a smaller one. – John Gardeniers Jul 07 '11 at 23:33

2 Answers2

2

7zip comes with 7z.exe which can be used on the command line or in scripts. However, you'll have to use a script to do the folder structure zipping that you want. I've done something similar, zipping log files by month then year. It's not pretty, but I can post the script if you'd like to see it.

Jim G.
  • 2,607
  • 1
  • 18
  • 19
0

Assume the directory name is \video .
Create a batch file with the following lines:

for /r \video %%a in (.) do @zip.exe -m "%%~pa\video" "%%~pa\*"
zip.exe -m -r Allvideo "\video\*"

This will create a final archive called allvideo.zip with a directory structure mirroring \video. Where video files once resided, video.zip will be found.

For this example I used the Zip utility found at: http://www.info-zip.org/Zip.html

Your server has enough horsepower for this activity, but, you may need to watch disk space. I'm only able to get ~5% size reduction by compressing a video file.

RobW
  • 2,766
  • 1
  • 17
  • 22