Synchronise Folders from PC to ATV2
#1
Hi Guys,

(Hopefully this is the right forum for this kind of thing Big Grin )
I've written a powershell script to synchronise a few folders between my PC and my 2 ATV2's and wondered if anyone was interested in it?

I use XBMC installed on my main PC to do the scraping of my movies using EmberMediaManager, and the script is set up to keep the backdrops folders I have sync'd on the ATV'2 (for random rotating backdrops on the ATV via skin settings), and also to sync the thumb folders.

Script is dependant on these library files that allow SSH connections via Powershell : http://sourceforge.net/projects/sharpssh...p/download

Script is quite small so just pasted in here:

Quote:Add-Type -Path ".\DiffieHellman.dll"
Add-Type -Path ".\Org.Mentalis.Security.dll"
Add-Type -Path ".\Tamir.SharpSSH.dll"

function Copy-FilesToATV
{
param
(
[string]$hostname,
[string]$username,
[string]$password,
[string]$SourceFolder,
[string]$DestinationFolder
)

$scpClient = New-Object "Tamir.SharpSsh.scp" "$HostName", "$UserName", "$Password"
$scpClient.Connect()

$BackdropFiles = Get-ChildItem $SourceFolder -recurse | where {!$_.PsIsContainer}

foreach ($Backdrop in $BackdropFiles)
{
$sourcefile = $Backdrop.FullName
$SubFolderName = $sourcefile.substring($SourceFolder.length,$SourceFile.Length-$SourceFolder.Length)
$RemoteFolderString = $SubFolderName -replace "\\","/"
$DestinationFile = $DestinationFolder+$RemoteFolderString

Write-Host "Copying $SourceFile to $DestinationFile"

$scpClient.Put($sourcefile,$DestinationFile)
}

$scpClient.Close()
}

# Movies Backdrops
Copy-FilesToATV "xxx.xxx.xxx.xxx" "yyyy" "zzzzzz" "E:/Media Center Files/Backdrops/Movies" "/private/var/mobile/Backdrops/Movies"
# TV Series Backdrops
Copy-FilesToATV "xxx.xxx.xxx.xxx" "yyyy" "zzzzzz" "E:\Media Center Files\Backdrops\TVShows" "/private/var/mobile/Backdrops/TVShows"
# thumbnail cache
Copy-FilesToATV "xxx.xxx.xxx.xxx" "yyyy" "zzzzzz" "C:\Users\XXXXXXX\AppData\Roaming\XBMC\userdata\Thumbnails" "/private/var/mobile/Library/Preferences/XBMC/userdata/Thumbnails"

Replace xxx.xxx.xxx.xxx with the IP of your ATV2
Replace yyyy with the username (default "root")
Replace zzzzzz with the password (default "alpine")
Replace XXXXXXX with your username on your PC

Currently it always copies the files, I'm working on getting the script to check 1st if the file exists on the ATV2 to try and cut down on the copy time (i.e. to replicate robocopy /MIR functionality)
QNAP TS670 NAS - 4x4TB Raided with NFS Support & Central MySQL DB
Pi 3 [Xbian] - Samsung 46" ES7000 Smart TV & HT-E5550 3D BD Sound System
Pi 3 [Xbian]  + Hyperion Ambilight- Samsung 48" Curved UE48JS9000 4k
PowerEthernet T1502 Powerline adapters
Reply

Logout Mark Read Team Forum Stats Members Help
Synchronise Folders from PC to ATV20