Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Autocopy Batch file from usb drive to hhd ?

26 Mar 2016   #1
HpBaxxter

Windows 64bit
 
 
Autocopy Batch file from usb drive to hhd ?

Hello,
I need a batch file which auto copy files from any USB drive when it connected to a folder in the hard disk .


My System SpecsSystem Spec
.
27 Mar 2016   #2
Ztruker

Windows 10 Pro X64
 
 

The problem trying to do that is the USB drive may have different drive letters assigned at different times so the batch file would need to be able to find the USB drive in order to copy from it.

You may be able to do this with PowerShell or VB Script but I don't know how to do so.
My System SpecsSystem Spec
28 Mar 2016   #3
HpBaxxter

Windows 64bit
 
 

Quote   Quote: Originally Posted by Ztruker View Post
The problem trying to do that is the USB drive may have different drive letters assigned at different times so the batch file would need to be able to find the USB drive in order to copy from it.

You may be able to do this with PowerShell or VB Script but I don't know how to do so.
I didn't find the right forum to post my question, so I posted it here
Every time I have a problem I find the solution here .
My System SpecsSystem Spec
.

24 Apr 2016   #4
HpBaxxter

Windows 64bit
 
 

any one else can help me ?
My System SpecsSystem Spec
24 Apr 2016   #5
UsernameIssues

W7 Pro SP1 64bit
 
 

You should (IMO) clarify what you mean by auto-copy.

Auto-copy could mean:
...attach USB drive
...and the files of interest automatically copy to the folder of interest on the hard disk.

OR

Auto-copy could mean:
...attach USB drive
...and you manually start the batch file
...that copies the files of interest automatically copy to the folder of interest on the hard disk.

Which is it?

Maybe your batch file could search thru each drive letter - looking for a certain file name. Once that file name is found, then you know that the USB drive of interest is attached and then copy the files.

Code:
IF EXIST D:\ID-FILE.txt copy D:\*.* C:\folder\*.*
IF EXIST E:\ID-FILE.txt copy E:\*.* C:\folder\*.*
IF EXIST F:\ID-FILE.txt copy F:\*.* C:\folder\*.*
I'm sure that there is a pretty way to enumerate the possible drive letters.
My System SpecsSystem Spec
25 Apr 2016   #6
Ztruker

Windows 10 Pro X64
 
 

If you control the content of the flash drive then you could put a batch file on it that does something like the following. We'll call it FlashAutocopy.bat.

xcopy \*.* %userprofile%\temp\autocopy\ /s/h/r/i/k/e/y /exclude FlashAutocopy.bat autorun.inf

(add /d if you only want to copy files that do not already exist in the autocopy folder)

xcopy \*.*says to copy all files and folders starting at the root of the flash drive.
%userprofile%\temp\autocopysays to copy to your profile directory, temp\autocopy folder.
/exclude FlashAutocopy.bat autorun.inf says to not copy these files.

You could also put a autorun.inf file in the root of the flash drive with one line it it that says:

open=
FlashAutocopy.bat

Then is autorun is enabled when you connect the flash drive it will automatically start FlashAutocopy.bat.
My System SpecsSystem Spec
25 Apr 2016   #7
RolandJS

Windows 7 Professional 64-bit
 
 

If the usb drive is always put into the same usb port, you can assign a drive letter to it. I gave mine Z [for example]. To keep your cd-dvd device from entering the fray, assign it drive letter I [for example], and let your batchfile not specify drive letter I. Do you have your OS partition as C and data partition assigned drive letter D? That will keep a universal batchfile from accidentally copying from your data partition.
My System SpecsSystem Spec
Reply

 Autocopy Batch file from usb drive to hhd ?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Batch File .bat to copy file from File Sharing & FTP Hosting
Hi all, Any idea how to write Batch File .bat to copy file from File Sharing & FTP Hosting to local directory. Current the File Sharing & FTP Hosting is SMARTFILE. I don't want to use WINSCP as the connector. Thanks
General Discussion
I need a batch file to open a random file within a certain folder/path
I want a batch to select and open a random link file in a folder i have. All the links are music videos I like to listen to, and I kind of want to just have an option for 'surprise me!'. I can change the file names if I have to, and I have a basic batch file ability. I know the simple commands,...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch file to copy files from C drive to USB
Hi all, To increase our backup solutions, we have decided to backup our SQL database every hour to a folder within the C drive (we couldn't get it to backup straight to a USB drive). So now we need a way (batch file best solution?) to copy these files to the USB drive, lets say every 1.05hours...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
How to create a batch file that will move files based on the file type
How to create a batch file that will move files based on the file type? My Requirement : I need a batch file to copy all .doc files in all my HardDisk to a removable disk say (Z: drive) . Can anyone make it possible using a batch file?Please...Its urgent...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:19.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App