Omniferum Posted March 14, 2011 Report Share Posted March 14, 2011 (edited) Forgot I ever made this topic. I eventually just wrote a powershell script that you just pass parameters to and away it goes. Copy and paste the below code into a blank txt file, save it as whateveryouwant.ps1 To use just type in the command line yourfilename.ps1 themovieyouwantrenamed You can even just pass an entire folder to it and it will iterate all of them. Still uses mediainfo to determine resolution Get-WmiObject Win32_LogicalDisk | ? {$_.Size -ne $null} | % {if (Test-Path ($_.DeviceID + "\Autorun.bat")) {$Drive = $_.DeviceID}} $MI = gci -r "$Drive\Programs" mediainfo.exe | % {$_.FullName} $Videos = gci "$args*" -Include *.nfo,*.mkv,*.mp4,*.avi,*.m2ts,*.wmv -Exclude ``[* | % { write-host $_.basename " " $Name = $_.basename -match '(.*)\d\d\d\d|(.*)' | %{$Matches[1]} | %{$_ -replace "[^\w\d]"," "} | %{($_).TrimEnd()} $Year = $_.basename -match '\d\d\d\d' | %{$Matches[0]} $SearchName = $Name + " " + "($Year)" $search = 'http://www.imdb.com/find?s=all&q=' + "$SearchName" $titlepage = (New-Object System.Net.WebClient).DownloadString($search) -match "/title/.*?/" | %{$Matches[0]} $scrape = (New-Object System.Net.WebClient).DownloadString('http://www.imdb.com' + "$titlepage") | Out-File "$($_.Directory)\$($_.basename).txt" $imdbpage = gc "$($_.Directory)\$($_.basename).txt" New-Object PSObject -Property @{ Dirn = $_.Directory Baname = $_.basename FName = $_.FullName Ext = $_.extension Resolution = &$MI "--Inform=Video;%Width%" $_.FullName | % { if (900 -lt $_ -and 1400 -gt $_) {echo 720p} else { if (1400 -lt $_) {echo 1080p} else { if (900 -gt $_) {echo SD $_} } } } IMDBName = "$imdbpage" -match "<title>(.*?)</" | %{$Matches[1]} | %{$_ -replace "[<>:`"\\/\|\?\*.]",""} | %{$_ -replace "'","'"} | %{$_ -replace "&","&"} | %{$_ -replace """,""} | %{$_ -replace "x22;",""} | %{$_ -replace " - IMDb",""} | %{$_ -replace " \(.*?\)",""} IMDBYear = "$imdbpage" -match "\((\d\d\d\d)\)" | %{$Matches[1]} IMDBBlurb = "$imdbpage" -match "<p>([\w\d].*?)</p>" | %{$Matches[1]} IMDBRating = "$imdbpage" -match "(\d\.\d)/10" | %{$Matches[1]} IMDBDirector = "$imdbpage" -match "Director:(.*?)</div>" | %{$Matches[1]} | %{$_ -replace "<.*?>",""} | %{$_ -replace "\s[\s]+"," "} IMDBWriters = "$imdbpage" -match "Writers:(.*?)</div>" | %{$Matches[1]} | %{$_ -replace ""","`""} | %{$_ -replace "<.*?>",""} | %{$_ -replace "\s[\s]+"," "} IMDBStars = "$imdbpage" -match "Stars:(.*?)</div>" | %{$Matches[1]} | %{$_ -replace "<.*?>",""} | %{$_ -replace "\s[\s]+"," "} IMDBSynopsis = "$imdbpage" -match ".*(<p>([\w\d].*?)<)" | %{$Matches[2]} | %{$_ -replace "'","'"} } del "$($_.Directory)\$($_.basename).txt" } $Videos | %{ #Just a piece of code to output all the relevant IMDB information to an accompanying .nfo file #Decided not to implement but keeping for shits and giggles #('Movie Title: ' + $_.IMDBName + "`n" + , #'Release Year: ' + $_.IMDBYear + "`n" + , #'Blurb: ' + $_.IMDBBlurb + "`n" + , #'Director:' + $_.IMDBDirector + "`n" + , #'Writers:' + $_.IMDBWriters + "`n" + , #'Stars:' + $_.IMDBStars + "`n" + , #'Synopsis: ' + $_.IMDBSynopsis + "`n" + , #'IMDB Rating: ' + $_.IMDBRating + '/10') | Out-File "$($_.Dirn)\$($_.Baname).nfo" # #Rename-Item "$($_.Dirn)\$($_.Baname).nfo" "`[$($_.Resolution)`] $($_.IMDBName) `($($_.IMDBYear)`).nfo" if ($_.IMDBName -ne $null) {Rename-Item $_.FName "`[$($_.Resolution)`] $($_.IMDBName) `($($_.IMDBYear)`)$($_.Ext)" -ErrorAction SilentlyContinue} } Edited March 11, 2012 by Omniferum Link to comment Share on other sites More sharing options...
Guest Guest Posted March 10, 2012 Report Share Posted March 10, 2012 Not working for me, I get a: The following usage of the path operator in batch-parameter substitution is invalid: %~xa">>name.xml For valid formats type CALL /? or FOR /? The syntax of the command is incorrect. Link to comment Share on other sites More sharing options...
Guest ROhan Posted May 31, 2012 Report Share Posted May 31, 2012 You're not running it correctly. Run it in Powershell not DOS. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now