Solved

Windows:  Unrar script

Posted on 2014-03-18
3
1,102 Views
Last Modified: 2014-03-19
Hi All,

I'm looking to do a bit of a tidy up on my media server.

I'm hoping someone can put together a script to unrar all my TV shows.

Around 50% of my shows are rar'ed in the following format;

D:\TV\Show Name\season n\show name s01e01\*.rar

I'd like them all to be extracted to the level below.

e.g.

D:\TV\Lost\season 1\Lost s01e01\Lost.s01e01.rar
D:\TV\Lost\season 1\Lost s01e01\Lost.s01e01.r00

would go to

D:\TV\Lost\season 1\Lost.s01e01.mkv



Could someone save me 2 days of unrar'ing by scripting it?



Many thanks

D
0
Comment
Question by:detox1978
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39939152
Don't know how to do this in batch, here's a Powershell solution:
# unrar archives to parent folder
# created for http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_28391754.html

$inputPath = "D:\TV"
$winRar = "C:\Program Files\WinRAR\WinRAR.exe"

gci $inputPath -Filter "*.rar" -Recurse | % {
    $parentFolder = $_.Directory.Parent.FullName
    Start-Process -FilePath $winRar -ArgumentList "e `"$($_.FullName)`" `"$parentFolder`"" -Wait
    #Remove-Item ($_.FullName.Substring(0,$_.FullName.Length-3) + "*") -Force
}

Open in new window


Replase $inputPath and $winRar to match your system's paths.

The script will look for any rar file in the $inputPath folder and unrar it in the parent folder (and wait until winrar finishes before moving on to the next archive).
Optionally, you can delete the archives by removing the # before Remove-Item

HTH,
Dan
0
 
LVL 2

Author Closing Comment

by:detox1978
ID: 39939947
Excellent thanks
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39940000
Glad I could help!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

18 Experts available now in Live!

Get 1:1 Help Now