Solved

Batch de-compression (zip + rar + ...) for a set of directories (recursively)

Posted on 2008-10-27
2
390 Views
Last Modified: 2013-11-10
I've a large number of *.txt files, all compressed in zip and rar containers.
The containers reside in a directory structure with 2-3 levels.
I need to recursively extract JUST the *.txt files to the root folder, leaving all the other files somewhere else.
0
Comment
Question by:go4java
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
Comment Utility
Here is a method which utilizes 7-Zip, a free zipping program which has good command-line support.
http://www.7-zip.org

Paste the script below into a text file with a .cmd extension.  Customize the value of the root variable with the location of the root folder.  Install 7-Zip and adjust the prog variable if it is installed to somewhere other than the default location.  Running the script will extract all .txt files from .zip and .rar archives to the root folder.


@echo off

setlocal
 

set root=c:\files

set prog=%programfiles%\7-zip\7z.exe
 

for /F "tokens=*" %%G in ('dir "%root%\*.zip" /A:-D /B /S') do "%prog%" e "%%G" -o"%root%" *.txt -r

for /F "tokens=*" %%G in ('dir "%root%\*.rar" /A:-D /B /S') do "%prog%" e "%%G" -o"%root%" *.txt -r

Open in new window

0
 

Author Comment

by:go4java
Comment Utility
Perfect, thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This video shows how use content aware, what it’s used for, and when to use it over other tools.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now