How to convert all your podcast for your ipod in a single click #2

Here I have an improved version of the previous script.

This version does not create a bat file but run the encoding directly, verify if the file has already been encoded, and if the file was processed completely ($inmedia.Properties.Duration.Minutes -ne $outmedia.Properties.Duration.Minutes)

What do you need:

This script should also set the metatag for the mp4 files but it does not work, I need to spend some time and investigate this problem

begin convert.ps1

————————————————————–

[Reflection.Assembly]::LoadFrom( (Resolve-Path “.taglib-sharp.dll”) )
$folders = get-childitem
Get-ChildItem $folders | Foreach {
if($_.Extension -eq ‘.mp4’ -or $_.Extension -eq ‘.wmv’ )
{
$in     = New-Object system.IO.FileInfo $_.fullname.ToString()
$indir  =  $in.Directory
$out    = New-Object system.IO.FileInfo $_.fullname.Replace(‘Podcasts’, ‘PodcastsEncoded’).Replace(‘.wmv’, ‘.mp4’)
$outdir = $out.Directory
$in        = New-Object system.IO.FileInfo $_.fullname.ToString()
$outdir.Create();

if(!$out.Exists)
{
.HandBrakeCLI.exe –input $in.fullname –output $out.fullname –preset=”iPod”
} else {
trap [Exception] {
.HandBrakeCLI.exe –input $in.fullname –output $out.fullname –preset=”iPod”
}
$inmedia = [TagLib.File]::Create($in.fullname)
$outmedia = [TagLib.File]::Create($out.fullname)
if($inmedia.Properties.Duration.Minutes -ne $outmedia.Properties.Duration.Minutes)
{
.HandBrakeCLI.exe –input $in.fullname –output $out.fullname –preset=”iPod”
}
}
$media = [TagLib.File]::Create($out.fullname)
$media.Tag.Title = $in.fullname.Replace($indir.fullname+””, “”);
$media.Tag.Album = $outdir.Name;
$media.Save()
}
}

————————————————————–

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s