Curious

Extraordinary Member
Joined
Mar 2, 2010
Messages
122
Hello,

I need to copy all files in 6 diretories to another device using only one diretory but with all files the files only.
Idon't want to replicate the original directiories in the new directory. On the files belonging the original directories.
Because if I use /s he copies all the original directories to the ney directory.
I need thia because it seems be much more quickly then using File Explorer.
Thank you for your help.
Curious
 
Solution
Hello Curious, It sounds like you want to use the xcopy command to consolidate files from multiple directories into a single new directory without retaining the structure of the original directories. You are correct that using the /s switch will replicate the directory structure, which isn't what you're looking for. Here's how to accomplish what you want using xcopy:
Code:
xcopy "C:\Path\to\Source1\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source2\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source3\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source4\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source5\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy...
Hello Curious, It sounds like you want to use the xcopy command to consolidate files from multiple directories into a single new directory without retaining the structure of the original directories. You are correct that using the /s switch will replicate the directory structure, which isn't what you're looking for. Here's how to accomplish what you want using xcopy:
Code:
xcopy "C:\Path\to\Source1\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source2\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source3\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source4\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source5\*.*" "D:\Path\to\Destination\" /H /R /Y xcopy "C:\Path\to\Source6\*.*" "D:\Path\to\Destination\" /H /R /Y

Explanation of the Command:​

  • "C:\Path\to\Source*\*.*": This specifies the source directories. Make sure to replace the paths with the actual paths of your source directories.
  • "D:\Path\to\Destination\": This is the destination directory where you want to copy the files.
  • /H: Copies hidden and system files as well.
  • /R: Overwrites read-only files.
  • /Y: Suppresses prompting to confirm you want to overwrite an existing destination file.

Batch Script:​

You can create a batch file containing these commands to execute them all at once. Just save the commands above in a text file with a .bat extension (like copyFiles.bat), and then run it.

Note:​

  • Be aware that if there are files with the same names in different source directories, the last copied file will overwrite the previous ones in the destination directory.
  • This method is indeed often faster than using File Explorer, especially when dealing with a large number of files.
If you need further clarification or assistance, feel free to ask! Happy copying!
 
Solution
Hello,

Thanks for your help but i don't get the command work.
I give the command and the system reply is that:

C:\Users\ASUS>Xcopy E:\TEST1\XCOPY (1)\ . E:\TEST2 /H /R /Y

Invalid number of parameters

C:\Users\ASUS>

Why?
 
Oh no, the classic "Invalid number of parameters" error! Let's unwrap this mess like a holiday gift.
The issue you're experiencing usually stems from the syntax of your command. Here’s the breakdown of what needs to be corrected:

Correct Syntax for xcopy Command​

To use the xcopy command properly, you should specify the source path followed by the destination path without any ambiguity. Based on the error message, it seems there's a slight problem with the command format. Here’s what your command should look like:
Code:
xcopy "E:\TEST1\XCOPY (1)\*.*" "E:\TEST2\" /H /R /Y

Key Points:​

  1. Quotes: If your path contains spaces or special characters (like parentheses), enclose the entire path in quotes.
  2. Specify Files: When using wildcards (like *.*), you need to specify that you want to copy all files from the source directory.
  3. Directory Designation: Make sure that the destination directory (E:\TEST2\) exists. If it doesn’t, you might need to create it first or xcopy won't be able to place the files.

Complete Example Command:​

Here’s how the command should be structured:
Code:
xcopy "E:\TEST1\XCOPY (1)\*.*" "E:\TEST2\" /H /R /Y

Troubleshooting Steps:​

  • Directory Existence: Double-check that E:\TEST2\ exists before running the command.
  • Testing the Command: Try running the command in a Command Prompt window with administrator privileges.
If this doesn’t work, share any error messages you receive, and we’ll get to the bottom of this together. Happy copying!
 
Talk about word salad from the bot. You just need quotes (") around your paths because you have a space in the path.