[Windows] How to automatically copy videos from USB drive to HTPC (Win 7)
#1
Problem:
Need to copy USB files automatically to HTPC without user intervention. On older version of Windows, this could be accomplished using autorun.inf, but in Windows 7, Microsoft has disabled autorun.inf for USB drives.

Solution:
Using two programs,
1. "USB Safely Remove"
2. Either a home-made .bat file, or by using freeware program SyncToy.

-------------------------------------

I'm creating this thread to help anyone else that tends to update their HTPC video files via USB. My HTPC is connected via wifi, but transfers are so slow that I generally resort to using a thumb drive to copy my latest videos.

XBMC also lacks an easy way to do this, so here is a solution:


1. Install USB Safely Remove. This will run on startup and replaces Microsoft's usual systray icon for removing USB drives. The main feature we want to use with this program is its ability to automatically run a program when a USB drive is plugged in:

Image

In the screenshot you can see the Global Autorun menu, and I've told it to run two programs after the device is plugged in. The first program copies files over, the second program is just a command to remove the USB drive safely.
You'll also see three options to the right. "Wait" will wait for one program to finish before starting the next. "Hide" will hide the programs while they run. "Drives only" will make sure the programs only run when drives are plugged in, and not USB keyboards/mice, etc.


2. Now we need to specify a program to run when the USB drive is plugged in. The program will need to be set up to copy files from one drive to another without user intervention. Currently I'm just using a batch file (usbcopy.bat), but you should be able to use SyncToy as an alternative. SyncToy will give you a nice interface which you use to set up folders you want to copy from one drive to another, but it also means it's one more program you need to install.
If you choose to use SyncToy, then once you've set up SyncToy with your folders (I won't provide instructions as it's pretty straight-forward), you need to use this command with USB Safely Remove:
"C:\Program Files\SyncToy\SyncToyCmd.exe" -R

Make sure you specify the right SyncToy folder above. This will automatically run SyncToy according to your settings. The -R flag will automatically run a sync with the folders you've specified. I have not tested this, but it should work without needing user intervention. The only issue with this is that it may cause an error message if you plug in a USB drive other than the normal drive you use to copy files. You can now skip to step 4.


3. Setting up a batch file instead of SyncToy. A .bat file for those unaware, is a text file that contains a series of DOS commands (copying, moving, deleting files, etc). They can also contain very basic programming. To easily create one, you just create a new TXT file, fill it with the commands you want, then just rename it to .BAT.

Here's how my usbcopy.bat looks like:


xcopy /e /y d:\Movies\*.* c:\Movies
xcopy /e /y d:\TV\*.* c:\TV


You can place the .BAT file either on your USB drive, or on your HTPC drive. It won't really make a difference. It would be cleaner to put the file on your HTPC drive, so that you don't have to put a .BAT file on one or more of your USB sticks.

So basically, I put my videos in either the Movies folder or TV folder on my USB ( D: ). I plug the drive in, and the batch file runs and automatically copies any files in those specified folders over to the HTPC. From the batch file, you can see my folders on the HTPC are C:\Movies and C:\TV. You will need to change these folders to suit your own folder layout on your HTPC.

With XCOPY, the /e switch copies all sub-folders. This is essential for TV shows. The /y switch automatically overwrites any existing files with the same name. This is incase you need to update an existing file with a new HD version or a repack.


4. OPTIONAL. One more step I added in USB Safely Remove is automatically disconnecting the USB drive once it's done copying. Just to help prevent the odd chance of corrupting the drive. USB Safely Remove has it's own command to safely remove the drive:
"C:\Program Files\USB Safely Remove\usr.exe" stop -d D:

Add that line to the list of AutoRun programs, as you can see in the screenshot above. Note that it specifies D: as the USB drive. You will need to change this to whatever drive letter your USB is.

If you will be plugging in other USB drives for whatever reason, then you don't want to add this option. Because what will happen is it will automatically disconnect the drive as soon as you plug it in. If you need to do other tasks with your USB drive, you will need to exit USB Safely Remove before you plug in the drive.
Reply

Logout Mark Read Team Forum Stats Members Help
[Windows] How to automatically copy videos from USB drive to HTPC (Win 7)0