Content of this article:
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, you will learn 2 useful methods, including backing up files with a professional backup software, copying files with autorun.inf and.bat file.
Easy way: Automatically copy files from/to USB drive when connected
In this part, you will use "USB plug in" feature in AOMEI Backupper Professional to automatically backup flash drive when plugged in or automatically copy files to USB drive when it is connected to your PC. To make it, you need to create a schedule backup with USB plug in feature first. Then, you just need to plug it into your computer and it will automatically backup files from/to USB drive.
Then, learn how to automatically copy files to USB drive when connected.
- Open AOMEI Backupper Professional, then click Backup and File Backup.
- Click Add Folder or Add File to select whatever you want to backup and click OK.
- Click the drop-down menu and select the connected flash drive as the target drive.
- (Required) Click Schedule at the bottom and then select USB plug in feature.
- Click Start Backup. After that, you need to check if it will automatically copy files when USB drive connected.
With the help of AOMEI Backupper Professional, it's easy to automatically copy files from/to USB drive when connected. But this version only support Windows 7/8/10/11. If you are a server user, you could consider using AOMEI Backupper Server (support server from 2003 to 20222).
★ How to backup files to AOMEI Cloud
There is a growing trend to backup files to cloud storage. Compared to a USB drive, cloud is a safer place to keep your important files because it is less subject to getting lost or infected. You can backup files to AOMEI Cloud if you have an AOMEI account. You'll get 1TB free storage for 15 days after you sign up for an AOMEI account.
Besides, you can use AOMEI Backupper to create a bootable media. With this bootable media, you can even copy files without booting Windows. This useful tool can also help you start your computer successfully when you experience a system crash.
Complicated way: Automatically copy files when USB drive connected
To automatically backup files with autorun.inf and .bat file, you need to create 5 files with Notepad, namely, AutoRun.inf, drive.ico, file.bat, launch.bat, invisible.vbs, and then run the backup task by clicking file.bat. Now, see the detailed steps below.
- Create an autorun file for the flash drive. Copy and paste the following code to notepad and save as AutoRun.inf. The file type needs to be all file.
- action=Click ok to Run game for Windows
▶ .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.
- Copy and paste the following code and save as file.bat. You can replace “picture”,”Favorites”,”videos” with your own needs.
- @echo off
- :: variables
- 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
- 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
- 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
- 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. After that, test if the batch file works for automatically copy files when USB drive connected.
Wrapping things up
Speaking of automatically copying files when USB drive connected, there are 2 useful ways for you. If you want an easy way, you could use "USB plug in" feature in AOMEI Backupper Professional. If you want to set a batch file, you could try the second yet complicated way.
Except for copying files, AOMEI Backupper still offers multiple useful features, allowing you to automatic backup Windows 7 to network drive, sync folder to Google Drive, delete old backup, clone dual boot hard drive, etc.