MCEBuddy Forum

 
  Forum  MCEBuddy 1.x  Questions and A...  Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning
Previous Previous
 
Next Next
New Post 3/9/2010 5:01 AM
Informative
User is offline resago
24 posts
No Ranking


Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning 
Modified By resago  on 3/9/2010 8:41:57 AM)

get the dll from the dvrms toolkit site

save the script as c:\metaname.ps1

make powershell run in remotesigned mode by typing "powershell Set-ExecutionPolicy RemoteSigned" at the start bar; if that fails, launch powershell (run as administrator) and at the prompt type: Set-ExecutionPolicy RemoteSigned

make a scheduled task to run "powershell c:\metaname.ps1" everynight (assuming you save it in c:\)

make mce buddy require a recording to be at least 1 day old

now my olympics files look like "Olympics - Opening Ceremony - From Vancouver blahblahblah.avi"

ENJOY!

 

 <code>

## metaname.ps1 ##
# get the Toub.MediaCenter.Dvrms.dll from the dvrms toolkit site and save in in c:\
# if you save it somewhere else, change the path below
[void][System.Reflection.Assembly]::LoadFile("C:\Toub.MediaCenter.Dvrms.dll")

# set the vars below to fit your situation
$source="e:\recorded tv"
$target="e:\recorded tv"

# this loop gets the Title, Subtitle, and Description from each wtv file and renames it
foreach ($file in gci "$source\*.wtv") {
    $wtv = New-Object Toub.Mediacenter.Dvrms.Metadata.DvrmsMetadataEditor($file)
    $attrlist = $wtv.GetAttributes()

# you can add or remove other metadata as you see fit
    $t = $attrlist["Title"].value -replace(":","-")
    $s = $attrlist["WM/SubTitle"].value -replace(":","-")
    $d = $attrlist["WM/SubTitleDescription"].value -replace(":","-")

# the multiple moves below handle cases of duplicates and long descriptions, only one will actually work.
    move "$file" "$target\$t-$s-$d.wtv"
    move "$file" "$target\$t-$s-$d-2.wtv"
    move "$file" "$target\$t-$s-$d-3.wtv"
    move "$file" "$target\$t-$s.wtv"
    move "$file" "$target\$t-$s-2.wtv"
    move "$file" "$target\$t-$s-3.wtv"
}

</code>

 
New Post 3/12/2010 5:16 AM
User is offline jackelmatador
1 posts
No Ranking


Re: Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning 
Modified By jackelmatador  on 3/12/2010 4:20:42 AM)
I tried this out and it works like a charm! The only downside seems to be if you put the script in a folder that has spaces such as "Program Files" even quotes won't work, I even tried Program~1 with no luck, oh well no big deal to have it in my root directory.One more thing the dll is hard to find, google search is your friend or here is the direct link http://babgvant.com/files/folders/misc/entry5687.aspx
 
New Post 3/12/2010 9:52 AM
User is offline resago
24 posts
No Ranking


Re: Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning 
Modified By resago  on 3/12/2010 9:03:12 AM)

yeah, I put it in a folder called metaname off c:\

I have refined it a little and will post the new source tonight.

It adjusts the name length on the fly so there is only 1 move/rename. I also took out handling duplicates cause you will just delete them anyway.

 

 
New Post 3/12/2010 1:34 PM
User is offline resago
24 posts
No Ranking


Re: Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning 

<code>

## metaname.ps1 ##
[void][System.Reflection.Assembly]::LoadFile("C:\Toub.MediaCenter.Dvrms.dll")
$source="e:\recorded tv"
$target="e:\recorded tv"
foreach ($file in gci "$source\*.wtv") {
    $wtv = New-Object Toub.Mediacenter.Dvrms.Metadata.DvrmsMetadataEditor($file)
    $attrlist = $wtv.GetAttributes()
    $t = $attrlist["Title"].value -replace(":","-")
    $s = $attrlist["WM/SubTitle"].value -replace(":","-")
    $d = $attrlist["WM/SubTitleDescription"].value -replace(":","-")
    $name = "$target\$t-$s-$d"
    $a = $name.length
    if ($a -gt 245)
        {$a=245}
    $name = $name.substring(0,$a)
    if (-not (test-path "$name.wtv"))
        {move "$file" "$name.wtv"}
}

</code>

 

 
New Post 3/18/2010 3:36 PM
User is offline mcebuddyadmin
275 posts
9th Level Poster


Re: Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning 

 Thanks Resago

 
Previous Previous
 
Next Next
  Forum  MCEBuddy 1.x  Questions and A...  Simple powershell script to rename wtv files using metadata so avi or mp4 filenames have meaning
  

Archived Forum

The old support forum is here http://archive.mcebuddy.com/forums/.  It also contains a lot of useful information on MCEBuddy.  If nothing shows within a forum, click on the "More Options" button and change the date range.

  

Who's Online

Online NowOnline Now: