Sync with Windows tablet/laptop

Jul 13, 2013 at 1:31 PM
Hi,

I created a simple script and a process to automatically keep my Media Center's recorded TV, MCE Buddy converted files, and those files on my Surface RT all in sync, including when I've watched it on my Surface. Let me know if you'd like me to share the script and the details of my configuration.

Thanks.
Coordinator
Jul 13, 2013 at 1:53 PM
Sure. I can host it for you ok the MCEBuddy sever or this site if possible

Jul 14, 2013 at 3:39 AM
The script and process is simple, but I figure I'd describe all of the details below.

In summary, on the target device you need to import the Windows Scheduled task "Sync TV" and the "PurgeWatchedTV" script. I exported this Sync TV job. Let me know how I can send you these two text files.

High Level Workflow:
I have my Media Center computer (PC name is "MediaCenter") recording TV to the location "Recorded TV". MCE Buddy converts these files (to mp4 in my case) into a folder called "Converted TV" on that same PC. On my Surface RT every time I logon it copies the delta of files from Converted TV to the SD card folder "TV" and removes any that have been removed from Converted TV. When I am away from home and after I have watched a show on my Surface, I move that file to a folder called "Watched TV" on the SD. When I come home and logon to my Surface it deletes the files from Watched TV, Converted TV, and Recorded TV with the Sync TV scheduled task and "PurgeWatchedTV" script.

Prerequisites:
  1. MCE Buddy file rename must include " ;" and then the original file name. I think the script also assumes no files on the root; i.e. it needs to have subfolders for the show names and Movies. For example, mine is: %ismovie%<Movies\%showname% ;%originalfilename%,%showname%\S%season%##E%episode%## - %airyear%_%airmonth%_%airday% - %episodename% ;%originalfilename%>
  2. MCE Buddy configured to keep files in sync.
  3. Homegroup.
  4. Shares setup for Homegroup on the hosting PC for Recorded TV and Converted TV. In my case \MediaCenter\Recorded TV and \MediaCenter\Converted TV.
  5. A folder on the tablet/laptop that contains the folder for the TV files, the script file, and a dedicated subfolder called "Watched TV". In my case I have D:\TV and then D:\TV\Watched TV and D:\TV\TV.
  6. Scheduled Task called "Sync TV" configured on the tablet/laptop.
"Sync TV" Scheduled Task details:
  1. Runs PurgeWatchedTV script. This script deletes any files in the Converted TV share that exist on the local D:\Watched TV folder, along with any empty folders. It then deletes the corresponding original .wtv file in the Recorded TV share.
  2. Runs robocopy mirror command between \MediaCenter\Converted TV and D:\TV\TV.
  3. The PurgeWatchedTV script also deletes any orphaned files between the Recorded TV and Watched TV. Sometimes this would happen for me if I happen to delete a show on my Media Center while the file is converting. In that case MCE Buddy doesn't automatically remove the converted file. This script will check for any files where if it exists in Converted TV but not in Recorded TV it will delete it from Recorded TV.
  4. The scheduled task is configured to only runs when it is on the home network. If this is not set then whenever you connect to a network while you are away it will attempt to run Sync TV. The problem would be that the robocopy command will attempt to retry on its own and never time out. I want it to behave that way on my home network, but not run at all while I am away. Fortunately this is a setting within Windows Scheduled Tasks.
The Parameters:
  1. The Media Center PC name and share. If they are different than what I have above you will need to modify the PurgeWatchedTV script with your share paths, as well as the path in the robocopy command in the Sync TV task.
  2. The converted TV file format. If it is not mp4 then you will need to modify the PurgeWatchedTV FileExtension variable.
  3. The target device's local storage path. If different then again modify the robocopy command and PurgeWatchedTV.
  4. Specify the type of OS in the Sync TV task during import. I'm not sure if this makes a difference, but good practice in any case.
  5. The user name that runs the task in Sync TV. When you import the task you need to specify the user name on the first screen. It should be you, assuming you have administrator rights on your own device.
  6. Your home network name in Sync TV task. When importing the task, under conditions specify the name of the home network you connect your device to. In my case my home network is the same as my WiFi.
Known Issues:
  1. The Sync TV task runs only at logon. No problem for me because every night I power my Surface off. You could customize or add other scheduled tasks, like to run during a specified schedule or on wakeup, but I haven't testing it. Also note the other potential limitations below with other types of tasks.
  2. The network needs to be fully initialized. Because the Scheduled Task is specified to only run on a particular network by design, the device needs to be fully connected to that network. The issue arises when my Surface boots up it takes about a second to connect to the WiFi. If the logon process happens prior to the connection then Sync TV doesn't run. I have to enter a pin to logon (Exchange policy) so this is not a problem for me because by the time I unlock and enter my pin it has connected to Wifi. There are settings in Windows that you can require a network connection prior to logging on. I have successfully configured this using group policies on a corporate domain, but I couldn't manage to get this to work with local policies on my Surface. I didn't troubleshoot too much because my setup works fine, but you might want to look into this if you have automatic logon or have the scheduled task on a time schedule.
  3. Obviously during the copy process it needs a persistent network connection. However it doesn't appear that Windows RT considers the command prompt copy as active and eventually the network goes to sleep. This interrupts the robocopy and it just sits there and waits for the network to come back. That's the other reason I have the task to run on logon because that is usually when I am planning on using it, giving it enough time to finish the copies. This is also why with the default config a Scheduled Task at a specified time probably doesn't work because the network won't be active. You could probably configure the network to stay active but then you would have a battery performance hit. You could also probably get fancy and have the scheduled task wake the network up, run the task, then put it back to sleep if it was sleeping prior to the job, but again I haven't bothered because it's not needed for my usage.
  4. I've only tested this on Windows RT but it should work on Windows 7 and 8.
  5. Viewing and managing these video files doesn't work well using the Windows 8 Video app: it's not organized into folders, it truncates the file names, and you can't manage the files to move them into the Watched TV folder. And viewing them using the Desktop Windows Explorer is a bit clunky (in RT 8.0). Therefore, I use this app "My Explorer", and set a favorite to the D:\TV\TV folder:
    http://apps.microsoft.com/webpdp/app/947f9272-9a7d-4311-88d8-6551fee8da9c
  6. I literally typed this script using Notepad on the touch screen on my Surface, so I didn't bother with much exception handling and it's not that optimized, but since it runs on the local LAN the script runs fast enough other than the actual copy.
Let me know if you have any questions and where I can send the files.
Coordinator
Jul 30, 2013 at 3:04 AM
Wow this is something, you can create a folder for on this the MCEBuddy server and upload your file there and post back here to the users on the details. You can find the server details on the README before posting thread.
Jul 30, 2013 at 3:39 AM
I uploaded a folder called "Sync TV" that contains the PurgeWatchedTV.vbs script and the exported Sync TV Scheduled Task.