Free | Automatically Copy Files When USB Drive Connected

You will learn to automatically copy files when USB drive connected with 2 ways, namely using professional backup software and batch file.

Ivy

By Ivy Updated on August 6, 2024

Share this: instagram reddit

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. 

Automatically Copy Files When USB Drive Connedted

Free & Easy way: Automatically copy files from/to USB drive when connected

In this part, you will use "USB plug in" feature in AOMEI Backupper Standard 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.

Before start, you need to do some preparations.
1. Prepare a USB flash drive and connect it to your computer. 
2. Download AOMEI Backupper, install and launch it.

Then, learn how to automatically copy files to USB drive when connected. 

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

File Backup

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

Add File or Folder

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

Select Backup Destination

  1. (Required) Click Schedule at the bottom and then select USB plug in feature.

Schedule Settings General

  1. Click Start Backup. After that, you need to check if it will automatically copy files when USB drive connected.

With the help of free file backup software, 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.

AOMEI Cloud

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.

Autorun Batch File

  1. 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.
  • [autorun]
  • icon=drive.ico 
  • open=launch.bat
  • action=Click ok to Run game for Windows
  • shell\open\command=launch.bat

Notes:
▶ .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.

  1. 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
  1. 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
  1. 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
  1. 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. 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.

Ivy
Ivy · Editor
Ivy is an editor of AOMEI Technology, she covers backup & restore,hard disk & partitions management and cloud files transfer and so on for AOMEI. She is an outgoing girl and enjoys helping people find solutions to their problems. She loves traveling, eating, reading and so on. She usually hangs out with friends at her leisure time.