MediaPortal Version: 1.1.2
MediaPortal Skin: Dark-Maya
Windows Version: Windows 7 64bit
Hi all,
This is my first script which I have written for mediaportal, but thought I would share it as it may help others!
Basically my setup is HTPC in living room with smallish HDD and NAS with Lots of HDD's.
As I use Freesat and the only sockets into the house are near the HTPC that is my main server / client setup and due to the case I can't move my HDD into it.
So following the advise in another thread I have setup two Recorded (using the IPTV as the second recorded TV location).
** BTW I tried to setup my recorded TV to be on my NAS but it refused to record anything **
I have written the following which needs to be input into a powershell script. - I think you can save it into a txt file and then rename it to .ps1
The Powershell script needs to be edited with your own location for Start location / and end locations.
You need the the guide set up to have Film: infront of any description i.e. "Film: The Incredibles" as it uses the Film: to find out if it a film or not.
I have the powershell script linked to a BAT file so that I can run it via windows task scheduler at 3 am and 3pm. - If anyone has a better way to run this please let me know (I did try to link it to the comskiplauncher but it did not appear to work) - I can provide the BAT code to run this if needed!
Hopefully this will work for some of you...
Cheers
Phil
MediaPortal Skin: Dark-Maya
Windows Version: Windows 7 64bit
Hi all,
This is my first script which I have written for mediaportal, but thought I would share it as it may help others!
Basically my setup is HTPC in living room with smallish HDD and NAS with Lots of HDD's.
As I use Freesat and the only sockets into the house are near the HTPC that is my main server / client setup and due to the case I can't move my HDD into it.
So following the advise in another thread I have setup two Recorded (using the IPTV as the second recorded TV location).
** BTW I tried to setup my recorded TV to be on my NAS but it refused to record anything **
I have written the following which needs to be input into a powershell script. - I think you can save it into a txt file and then rename it to .ps1
The Powershell script needs to be edited with your own location for Start location / and end locations.
You need the the guide set up to have Film: infront of any description i.e. "Film: The Incredibles" as it uses the Film: to find out if it a film or not.
I have the powershell script linked to a BAT file so that I can run it via windows task scheduler at 3 am and 3pm. - If anyone has a better way to run this please let me know (I did try to link it to the comskiplauncher but it did not appear to work) - I can provide the BAT code to run this if needed!
Hopefully this will work for some of you...
Cheers
Phil
Code:
# Move Recorded TS Files to other locations
# Owner : Philip Bath
# Version : 0.2
# Notes : Set the StartLocation, FilmLocation and OtherLocation
# The script then needs to be run via a BAT file
# Notes1 : You can also turn on / off (1 = on, 0 = off) to delete the XML files that will be left
# In the recordedTV location, off moves it with the files
$StartLocation = "C:\Users\Public\Recorded TV\" # "C:\Users\Public\Recorded TV"
$FilmLocation = "\\NAS\VideoDownloads\"
$OtherLocation = "\\NAS\recorded tv\"
$DeleteFilm = 1
$DeleteOther = 0
# Build an array of the .TS files
$TSlist = Get-ChildItem -Path $StartLocation | Where-Object {$_.Name -like "*.ts"}
$Alllist = Get-ChildItem -Path $StartLocation | Where-Object {$_.Name -notlike "*.ts"}
# If the TSList is empty then stop here
if (!$TSlist)
{
}
else
{
foreach ($TSfile in $TSlist)
{
# Check to see if the file starts with Film_
if ($TSfile.Name.IndexOf("Film_") -ne -1)
{
foreach ($Allfile in $Alllist)
{
$tmp = $TSfile.Name.IndexOf(".ts")
if ($Allfile.Name.IndexOf($TSfile.Name.SubString(0,$tmp)) -ne -1)
{
if ($DeleteOther -eq 1)
{
# Delete the file
Remove-Item $StartLocation$Allfile
}
else
{
# Move to the OtherLocation
Rename-Item $StartLocation$AllFile $Allfile.Name.subString(5)
ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $Allfile.Name.subString(5) /MOV /R:2 /w:300 /NFL /NDL
}
}
}
# Now rename file (remove Film_ ) then
Rename-Item $StartLocation$TSFile $TSfile.Name.subString(5)
ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $FilmLocation.subString(0,$FilmLocation.Length-1) $TSfile.Name.subString(5) /MOV /R:2 /w:300 /NFL /NDL
}
else
{
# Section Used if not Film
foreach ($Allfile in $Alllist)
{
$tmp = $TSfile.Name.IndexOf(".ts")
if ($Allfile.Name.IndexOf($TSfile.Name.SubString(0,$tmp)) -ne -1)
{
if ($DeleteOther -eq 1)
{
# Delete the file
Remove-Item $StartLocation$Allfile
}
else
{
# Move to the OtherLocation
ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $Allfile.Name /MOV /R:2 /w:300 /NFL /NDL
}
}
}
# Move to the OtherLocation
ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $TSfile.Name /MOV /R:2 /w:300 /NFL /NDL
}
}
}