DOS Xcopy Command Help: Copy Folders to Multiple Locations

  • Thread starter Dave Ritche
  • Start date
  • Tags
    Dos
In summary: 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)
  • #1
Dave Ritche
70
6
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!
 
Technology news on Phys.org
  • #2
https://support.microsoft.com/en-us/kb/240268
 
  • Like
Likes Dave Ritche
  • #3
theodoros.mihos said:
https://support.microsoft.com/en-us/kb/240268
Thanks...
 
  • #4
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
jedishrfu said:
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
If you know the drive then you know the root folder.
 
  • Like
Likes Dave Ritche
  • #7
jedishrfu said:
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
I don't 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
I'd write a perl script. Use the File:Copy package.
 
  • Like
Likes Silicon Waffle
  • #10
Dave Ritche said:
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
Silicon Waffle said:
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
Dave Ritche said:
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
Silicon Waffle said:
You can also use Windows's vb script .
Is it Visual Basic, or Javascript?
 
  • #14
meBigGuy said:
Is it Visual Basic, or Javascript?
It's VB script. That will also help to get things in the storage transferred :wink: ...intentionally.
 
  • #15
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)
 

1. What is the purpose of the DOS Xcopy command?

The DOS Xcopy command is used to copy files and folders from one location to another in the Windows operating system. It is a fast and efficient way to transfer large amounts of data.

2. How do I use the Xcopy command to copy folders to multiple locations?

To copy folders to multiple locations using the Xcopy command, you will need to use the /s parameter followed by the source folder and the destination folders. For example: xcopy C:\Folder1\ /s C:\Folder2\ C:\Folder3\ will copy Folder1 to both Folder2 and Folder3.

3. Can I use the Xcopy command to copy subfolders and their contents?

Yes, the Xcopy command has a /e parameter that allows you to copy subfolders and their contents along with the main folder. For example: xcopy C:\Folder1\ /e C:\Folder2\ will copy Folder1 and all of its subfolders to Folder2.

4. What if I want to exclude certain files or folders from being copied?

You can use the /exclude parameter to specify a text file containing a list of files or folders to exclude from the copy process. For example: xcopy C:\Folder1\ /s /exclude:C:\exclude.txt C:\Folder2\ will copy Folder1 to Folder2 while excluding the files and folders listed in the exclude.txt file.

5. Is there a way to copy folders and their contents without overwriting existing files?

Yes, the /y parameter can be used to automatically overwrite existing files without prompting for confirmation. If you do not want to overwrite existing files, you can use the /-y parameter to be prompted for each file before it is overwritten.

Similar threads

  • Programming and Computer Science
Replies
4
Views
748
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
14
Views
4K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
12
Views
4K
  • Programming and Computer Science
Replies
1
Views
975
  • Programming and Computer Science
Replies
1
Views
3K
Back
Top