Solved

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

Posted on 2008-10-27
2
398 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
If your app took Google’s lash recently, here are the 5 most likely reasons.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.

808 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