# DOS Xcopy command help

Hello!
I am trying to run Dos copy command butim a confused a little about using it to copy folders to multiple folders.My problem is to write a command that will copy all folders from a source that could be something like G:\ or H:\ i.e from USB drive.Can i use G and H both at a time?

## Answers and Replies

Related Programming and Computer Science News on Phys.org
Thanks...

jedishrfu
Mentor
An alternative approach is to zip up all the folders and files, copy the compressed zip to where you want and then unzip it in the new location.

You might need to download the zip tool though and will need sufficient space for the zip file and the unzipped files.

Dave Ritche
An alternative approach is to zip up all the folders and files, copy the compressed zip to where you want and then unzip it in the new location.

You might need to download the zip tool though and will need sufficient space for the zip file and the unzipped files.
Thanks but what if i don't know the files or folders already?
I'm looking for a command that will copy all the folders of a drive.....

jedishrfu
Mentor
If you know the drive then you know the root folder.

Dave Ritche
If you know the drive then you know the root folder.
Okay!
How about performing this operation:
A USB drive is inserted and the drive name is G:\.I want to copy all the folders except .exe files..and want to do this silently mean without displaying the prompt window.
Should i use @Echo off?

jedishrfu
Mentor
I dont think you can make the operation entirely invisible. I think you'll still have a blank window popup at best.

http://www.computerhope.com/echohlp.htm

You can turn command echo off but you'll need to redirect command error messages and output to file or to nul.

Dave Ritche
meBigGuy
Gold Member
I'd write a perl script. Use the File:Copy package.

Silicon Waffle
Okay!
How about performing this operation:
A USB drive is inserted and the drive name is G:\.I want to copy all the folders except .exe files..and want to do this silently mean without displaying the prompt window.
Should i use @Echo off?
You can also use Windows's vb script .
JavaScript:
::file copy
@echo off
/min
set command=xcopy /s /c /d /e /h /i /r /y /exclude:YourExcludedExeFiles.txt
echo off
%command% "%G%" "%DestinationDrive%"
@echo off
Run your wscript to createObject without arguments e.g
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
and feed its second parameter with the above script file.

If you need this process to run automatically when the USB is inserted, I guess you would probably need to add an autoconf file also for the task.

You can also use Windows's vb script .
JavaScript:
::file copy
@echo off
/min
set command=xcopy /s /c /d /e /h /i /r /y /exclude:YourExcludedExeFiles.txt
echo off
%command% "%G%" "%DestinationDrive%"
@echo off
Run your wscript to createObject without arguments e.g
CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
and feed its second parameter with the above script file.

If you need this process to run automatically when the USB is inserted, I guess you would probably need to add an autoconf file also for the task.
Thanks.
I don't know much about Javascript..can you explain a bit about the commands and code you used?

Thanks.
I don't know much about Javascript..can you explain a bit about the commands and code you used?
:: <<< is for comment
/min <<< always minimize executed console/windows
set command=xxx <<<< set label 'command'
/exclude:xxx.txt <<<< exclude option for all filenames written in xxx.txt
%command%"%G%""%DestinationDrive%" <<< execute the set command
echo off <<< no output, keep things silent please

Last edited:
meBigGuy
Gold Member
You can also use Windows's vb script .
Is it Visual Basic, or Javascript?

Is it Visual Basic, or Javascript?
It's VB script. That will also help to get things in the storage transferred ...intentionally.

meBigGuy
Gold Member
The OP saw the Javascript fomated code window and assumed it is Javascript. Just trying to point that out.

If a perl script is desired, I can supply an example. But, I need a requirement for how the script will be invoked.
For example, how does the program know what drive letter to copy. Let's call the command program dumpIt. Would the user type dumpIt G: in a command window?
Or, do you need DumpIt to appear as a right mouse context for any file on the drive? Or, is dumpIt a right mouse context for the drive? Or, do we try to register a service that will run dumpIt on any USB drive placed on the computer? (not sure how to do that one)