Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
2  
Why not zip everything at once? –  84104 Jul 7 '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 7 '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. –  Zoredache Jul 7 '11 at 21:22
    
BTW what you are asking for is certainly possible. –  Zoredache Jul 7 '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 7 '11 at 23:33

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.