DOS Xcopy command help

  • #1
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?
Thanks in advance!
 

Answers and Replies

  • #4
12,031
5,693
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.
 
  • Like
Likes Dave Ritche
  • #5
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.....
 
  • #6
12,031
5,693
If you know the drive then you know the root folder.
 
  • Like
Likes Dave Ritche
  • #7
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?
 
  • #8
12,031
5,693
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.
 
  • Like
Likes Dave Ritche
  • #9
meBigGuy
Gold Member
2,323
405
I'd write a perl script. Use the File:Copy package.
 
  • Like
Likes Silicon Waffle
  • #10
156
203
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.
 
  • #11
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?
 
  • #12
156
203
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:
  • #13
meBigGuy
Gold Member
2,323
405
  • #14
156
203
Is it Visual Basic, or Javascript?
It's VB script. That will also help to get things in the storage transferred :wink: ...intentionally.
 
  • #15
meBigGuy
Gold Member
2,323
405
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)
 

Related Threads on DOS Xcopy command help

  • Last Post
Replies
12
Views
3K
  • Last Post
Replies
5
Views
2K
Replies
1
Views
2K
  • Last Post
Replies
3
Views
4K
Replies
6
Views
3K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
19
Views
5K
  • Last Post
Replies
4
Views
4K
  • Last Post
Replies
7
Views
5K
  • Last Post
Replies
2
Views
2K
Top