home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Support
General Support
Powershell script to move Recorded TV
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="pbathuk" data-source="post: 699074" data-attributes="member: 108858"><p><strong>MediaPortal Version</strong>: 1.1.2</p><p><strong>MediaPortal Skin</strong>: Dark-Maya</p><p><strong>Windows Version</strong>: Windows 7 64bit</p><p></p><p>Hi all,</p><p></p><p>This is my first script which I have written for mediaportal, but thought I would share it as it may help others!</p><p>Basically my setup is HTPC in living room with smallish HDD and NAS with Lots of HDD's. </p><p>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.</p><p></p><p>So following the advise in another thread I have setup two Recorded (using the IPTV as the second recorded TV location).</p><p>** BTW I tried to setup my recorded TV to be on my NAS but it refused to record anything **</p><p></p><p>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 </p><p></p><p>The Powershell script needs to be edited with your own location for Start location / and end locations.</p><p></p><p>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.</p><p></p><p>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!</p><p></p><p>Hopefully this will work for some of you...</p><p></p><p>Cheers</p><p>Phil</p><p></p><p>[CODE]</p><p># Move Recorded TS Files to other locations</p><p></p><p># Owner : Philip Bath</p><p># Version : 0.2</p><p># Notes : Set the StartLocation, FilmLocation and OtherLocation</p><p># The script then needs to be run via a BAT file</p><p># Notes1 : You can also turn on / off (1 = on, 0 = off) to delete the XML files that will be left</p><p># In the recordedTV location, off moves it with the files</p><p></p><p>$StartLocation = "C:\Users\Public\Recorded TV\" # "C:\Users\Public\Recorded TV"</p><p>$FilmLocation = "\\NAS\VideoDownloads\"</p><p>$OtherLocation = "\\NAS\recorded tv\"</p><p>$DeleteFilm = 1</p><p>$DeleteOther = 0</p><p></p><p># Build an array of the .TS files</p><p></p><p>$TSlist = Get-ChildItem -Path $StartLocation | Where-Object {$_.Name -like "*.ts"}</p><p>$Alllist = Get-ChildItem -Path $StartLocation | Where-Object {$_.Name -notlike "*.ts"}</p><p></p><p># If the TSList is empty then stop here</p><p> if (!$TSlist) </p><p> {</p><p> }</p><p> else</p><p> {</p><p> foreach ($TSfile in $TSlist)</p><p> {</p><p> # Check to see if the file starts with Film_</p><p> if ($TSfile.Name.IndexOf("Film_") -ne -1)</p><p> {</p><p> foreach ($Allfile in $Alllist)</p><p> {</p><p> $tmp = $TSfile.Name.IndexOf(".ts")</p><p> if ($Allfile.Name.IndexOf($TSfile.Name.SubString(0,$tmp)) -ne -1)</p><p> {</p><p> if ($DeleteOther -eq 1)</p><p> {</p><p> # Delete the file</p><p> Remove-Item $StartLocation$Allfile</p><p> }</p><p> else</p><p> {</p><p> # Move to the OtherLocation </p><p> Rename-Item $StartLocation$AllFile $Allfile.Name.subString(5)</p><p> ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $Allfile.Name.subString(5) /MOV /R:2 /w:300 /NFL /NDL</p><p> }</p><p> }</p><p> }</p><p> # Now rename file (remove Film_ ) then</p><p> Rename-Item $StartLocation$TSFile $TSfile.Name.subString(5)</p><p> ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $FilmLocation.subString(0,$FilmLocation.Length-1) $TSfile.Name.subString(5) /MOV /R:2 /w:300 /NFL /NDL</p><p> }</p><p> else</p><p> {</p><p> # Section Used if not Film</p><p> foreach ($Allfile in $Alllist)</p><p> {</p><p> $tmp = $TSfile.Name.IndexOf(".ts")</p><p> if ($Allfile.Name.IndexOf($TSfile.Name.SubString(0,$tmp)) -ne -1)</p><p> {</p><p> if ($DeleteOther -eq 1)</p><p> {</p><p> # Delete the file</p><p> Remove-Item $StartLocation$Allfile</p><p> }</p><p> else</p><p> {</p><p> # Move to the OtherLocation </p><p> ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $Allfile.Name /MOV /R:2 /w:300 /NFL /NDL</p><p> }</p><p> }</p><p> } </p><p> # Move to the OtherLocation</p><p> ROBOCOPY $StartLocation.subString(0,$StartLocation.Length-1) $OtherLocation.subString(0,$OtherLocation.Length-1) $TSfile.Name /MOV /R:2 /w:300 /NFL /NDL</p><p> }</p><p> }</p><p> }</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="pbathuk, post: 699074, member: 108858"] [b]MediaPortal Version[/b]: 1.1.2 [b]MediaPortal Skin[/b]: Dark-Maya [b]Windows Version[/b]: 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 } } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Support
General Support
Powershell script to move Recorded TV
Contact us
RSS
Top
Bottom