Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows:  Unrar script

Posted on 2014-03-18
3
Medium Priority
?
1,236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 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 35

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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