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