Solved

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

Posted on 2008-10-27
2
392 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
ID: 22814430
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
ID: 22814619
Perfect, thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
Viewers will learn how to use the Hootsuite Dashboard.

920 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

16 Experts available now in Live!

Get 1:1 Help Now