Solved

Windows:  Unrar script

Posted on 2014-03-18
3
1,088 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
Comment Utility
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
Comment Utility
Excellent thanks
0
 
LVL 34

Expert Comment

by:Dan Craciun
Comment Utility
Glad I could help!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
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…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

9 Experts available now in Live!

Get 1:1 Help Now