Solved

Windows:  Unrar script

Posted on 2014-03-18
3
1,186 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 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 35

Expert Comment

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

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

617 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