Home » Questions » Computers [ Ask a new question ]

How can I automatically copy files to a USB drive when I connect it to my computer?

How can I automatically copy files to a USB drive when I connect it to my computer?

I am looking for a solution for copying all the files from a specific directory on the hard drive, to a specific directory on a USB memory device, once this device is connected.

Asked by: Guest | Views: 89
Total answers/comments: 4
Guest [Entry]

"Windows 7 and autosync to your flash/USB device on insert!

Download SyncToy and establish your folder pairing and sync name(""SyncTest"")

see: How-to: Using SyncToy to make a nightly mirror of My Documents

Run computer management console
Event viewer/windows logs/system
Find the media insertion event

“The Portable Device Enumerator Service service entered the running state.”
(You may need to clear you event log and eject/reinsert you media to trigger this log event)

In the upper event window, right click on the event and select ""Attach Task To This Event""
Windows open ""Create Basic Task Window""
Give your task a name and hit next
Event information is already filled in, next
Action should show ""Start a Program"", next
In the Start a Program window, browse to SyncToyCmd.exe(or your chosen sync app)
Add arguments. If your backup pairing is called SyncTest, enter ""-RsyncTest"". Do not add quotes, do not add a space after the -R, SyncToy command line(or maybe Windows 7) is case sensative so SyncTest does not equal synctest!
Next, Finish

You can run the task right from Task Scheduler to verify it works. Now the only other problem I had was running my laptop on batteries, in Task Manager under the conditions tab, uncheck ""Start the task only if the computer is on AC power"", otherwise task will only run when AC is plugged in.

Also, as USB polls and disconnects/reconnects, this task will run every couple of minutes, actually kinda cool, it's auto-syncing to the USB HDD all the time :)"
Guest [Entry]

"I just use a AUTORUN.INF with a few batches to sync key folders. Very simple very effective.

Also, if you have a read only,archived autorun.inf file its hard contract usb-stick virus's"
Guest [Entry]

"You are simply just forgetting to """" and end "".\dectory\"" ← That end \ slash as well.

The original batch formula works, It is just now days, There are a lot of spaces in directories, batch files and command prompt HATE those.

How mine looks:

xcopy ""F:\Web Stuff\Web Dev\Dev_FactorY Designs\*.*"" "".\HTML_PROJ\Web Stuff\Web Dev\Dev_FactorY Designs\"" /e /y"
Guest [Entry]

"Under Linux, instead of having a program running continuously to listen for events, you can use the already running ones. You can add some hooks to udev that mounts the device to a temporary location and then launches rsync to synchronize a bunch of directories.

By the way you can define specific actions according to your device signature: synchronize your work documents when a specific key is inserted, or your music if a USB mass storage MP3 player is inserted, or your books when plugging a Kindle there."