Skip to main content
deleted 456 characters in body
Source Link
DavidPostill
  • 158.5k
  • 77
  • 365
  • 408

How do I force xcopy to assume the destination is a file not a directory?

Add an asterix * to the destination file name, like so:

C:\IAM\New_ADuser_mustang.ps1*

 

This works because:

When copying a single file with XCOPY, there is no option to indicate if the destination is a filename or a directory (with the filename defaulting to that of the source file).

In such cases XCOPY will prompt with a (locale specific) message like:

C:\> xcopy foo.txt bar.txt
Does foo.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Adding a wildcard (*) to the end of the destination will suppress this prompt and default to copying as a file:

C:\> xcopy foo.txt bar.txt*
C:foo.txt
1 File(s) copied

This requires the source and target file extensions to be the same length, typically 3 characters.

Source Xcopy - Copy files and folders - Windows CMD - SS64.comSource: Xcopy - Copy files and folders - Windows CMD - SS64.com


Further Reading

How do I force xcopy to assume the destination is a file not a directory?

Add an asterix * to the destination file name, like so:

C:\IAM\New_ADuser_mustang.ps1*

 

When copying a single file with XCOPY, there is no option to indicate if the destination is a filename or a directory (with the filename defaulting to that of the source file).

In such cases XCOPY will prompt with a (locale specific) message like:

C:\> xcopy foo.txt bar.txt
Does foo.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Adding a wildcard (*) to the end of the destination will suppress this prompt and default to copying as a file:

C:\> xcopy foo.txt bar.txt*
C:foo.txt
1 File(s) copied

This requires the source and target file extensions to be the same length, typically 3 characters.

Source Xcopy - Copy files and folders - Windows CMD - SS64.com

How do I force xcopy to assume the destination is a file not a directory?

Add an asterix * to the destination file name, like so:

C:\IAM\New_ADuser_mustang.ps1*

This works because:

Adding a wildcard (*) to the end of the destination will suppress this prompt and default to copying as a file

Source: Xcopy - Copy files and folders - Windows CMD - SS64.com


Further Reading

Source Link
DavidPostill
  • 158.5k
  • 77
  • 365
  • 408

How do I force xcopy to assume the destination is a file not a directory?

Add an asterix * to the destination file name, like so:

C:\IAM\New_ADuser_mustang.ps1*

When copying a single file with XCOPY, there is no option to indicate if the destination is a filename or a directory (with the filename defaulting to that of the source file).

In such cases XCOPY will prompt with a (locale specific) message like:

C:\> xcopy foo.txt bar.txt
Does foo.txt specify a file name
or directory name on the target
(F = file, D = directory)?

Adding a wildcard (*) to the end of the destination will suppress this prompt and default to copying as a file:

C:\> xcopy foo.txt bar.txt*
C:foo.txt
1 File(s) copied

This requires the source and target file extensions to be the same length, typically 3 characters.

Source Xcopy - Copy files and folders - Windows CMD - SS64.com