-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy-item does not create folder to destination when copy one file #18828
Comments
Use -force to create the necessary folder structure. |
Big thanks @doctordns for your propose, but: |
I agree that on-demand target-directory creation would be useful, but I suggest framing this as an enhancement that requires opt-in, and the syntax for that needs to be worked out. In fact, this has come up before, in the context of #12805, where I've proposed an on-demand-directory-creation switch tentatively named The - cumbersome - workaround for now is: # Note: New-Item -Type Directory -Force returns a directory-info object either for a preexisting directory
# or one created on demand.
Copy-Item -Path .\test.txt -Destination (New-Item -Type Directory -Force .\TestFolder) |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
1 similar comment
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Prerequisites
Steps to reproduce
Hi,
When running the following command:
Copy-Item -Path .\test.txt -Destination .\TestFolder\
I do get the following error:
Copy-Item: The filename, directory name, or volume label syntax is incorrect. : 'C:\Temp\TestFolder\'
This is the same behavior on PowerShell and also Windows PS.
Expected behavior
Obviously I'm expecting that copy-item creates the folder as I asked and copy the file into it. And this is actually what it does when copy folder instead single file.
Actual behavior
Error details
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: