By Ivy / Last Updated September 24, 2020

How to automatically copy files when USB drive connected to your PC?

“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.”

Do you have similar problem? How to automatically copy files when USB drive connected? If so, keep reading below to learn the detailed steps. In the following, we mainly talk about 2 methods, including copying files with autorun.inf and.bat file, backing up files with a trust and reliable backup software for Windows PC. And the first one is complicated and easy to make mistake while the second is simple.

Complicated way: Automatically copy files when USB drive connected

To automatically backup files with autorun.inf and .bat file, you need to create the following files with Notepad. Then, click file.bat to run the backup task.

AutoRun.inf

drive.ico

file.bat

launch.bat

invisible.vbs.

Autorun Batch File

Now, see the detailed steps below.

Step 1. Create an autorun file for the flash drive. Copy and paste the following code to notepad and save as AutoRun.inf.

[autorun]

icon=drive.ico

open=launch.bat

action=Click ok to Run game for Windows

shell\open\command=launch.bat

Note:

.ico refers to a png file. You have to find a png file and save it to the flash drive, then and name it as drive.ico.

open is used to launch the batch file.

action refers to open whatever you want.

Step 2. Copy and paste the following code and save as file.bat. You can replace “picture”,”Favorites”,”videos” with your own needs.

@echo off

:: variables

/min

SET odrive=%odrive:~0,2%

set backupcmd=xcopy /s /c /d /e /h /i /r /y

echo off

%backupcmd% "%USERPROFILE%\pictures" "%drive%\all\My pics"

%backupcmd% "%USERPROFILE%\Favorites" "%drive%\all\Favorites"

%backupcmd% "%USERPROFILE%\videos" "%drive%\all\vids"

@echo off

cls

Step 3. create a VB Script file to batch file as invisible. Type the following syntax in the notepad and save as invisible.vbs.

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Step 4. Make a batch file to run vb script and file.bat. Type the following code in the notepad and save as launch.bat.

wscript.exe \invisible.vbs file.bat

Step 5. create a folder in the root of flash drive and name it as all. Then, save all the files in the folder and make it hidden.

Step 6. Plug the flash drive into a computer and try out.

Reading here, you may feel terrible if you are not familiar with autorun.inf and batch file. Some users may say, ”I have no idea what this is.” Now, here comes a question: Is there an easier way to automatically copy files from/to USB drive when connected? You can use “USB plug in” feature in AOMEI Backupper Professional. It’s designed to solve this problem.

Easier way: Automatically copy files from/to USB drive when connected

To be honest, everyone is afraid of making mistakes and willing to use the simple way. In view of this reason, I’ll introduce you AOMEI Backupper Professional and tell you how to automatically copy files with it. It not only automatically backup flash drive when plugged in, but also automatically copy files to USB drive when connected. The only difference is to use the flash drive as source drive or target drive.

To achieve this goal, The premise is to create a schedule backup with USB plug in. Then, you just need to plug it into your computer again and it will automatically backup files from/to USB drive.

Before start, you need to do some preparations.

1. Prepare a USB flash drive and connect it to your computer.

2. Download AOMEI Backupper Professional, install and launch it.

Then, see the specific steps below. Here, I’ll show you how to automatically copy files to USB drive when connected. To automatically backup files from USB, you just need to use the flash drive as source disk.

Step 1. Open AOMEI Backupper Professional, then click Backup and File Backup.

File Backup

Step 2. Click Add Folder or Add File to select whatever you want to backup and click OK.

Add File or Folder

Step 3. Click the drop-down menu and select the connected flash drive as the target drive.

Select Backup Destination

Step 4(Required). Click Schedule at the bottom and then select USB plug in under the General tab.

Schedule Settings General

Step 5. Click Start Backup.

Step 6(Important). Plug out the USB drive and plug it into your computer again. Then, it will automatically copy files when USB drive connected.

With this software, automatically copying files from/to USB drive when connected becomes easier. But this version only support Windows 7/8/10. So, if you are running server-based operating system, you can consider using AOMEI Backupper Server. It support all kinds of servers, such as, Server 2003/2008/2012/2016, etc.

Wrapping things up

Speaking of automatically copying files when USB drive connected, there are 2 ways for you. But the first is complicated and difficult to understand. So, you’d better backup files with USB plug in feature.

AOMEI Backupper is a cost-effective software, because it offers you complete backup and restore solution as well as all the clone features. You are allowed to automatic backup Windows 7 to network drive, sync folder to Google Drive, delete old backup, clone dual boot hard drive, etc. Besides, it supports lifetime free upgrade to the latest version.

Download AOMEI Backupper and protect your files all life.