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 with "\*" fails if no subdirectory is present #12805
Comments
I agree that the behavior is counter-intuitive. What happens is that if the The workaround is to make sure that the target path exists as a directory beforehand. You can mitigate the problem somewhat if you append a Although it would technically be a breaking change, it would make sense to default to assuming a container (directory) as the target path in case multiple paths / a wildcard-based path is specified as input, possibly complemented with a new switch such as |
Thanks for declaration. I don't think a new switch is necessary. If Copy-Item -Path "C:\Logfiles*" -Destination "C:\Drawings\Logs" worked as expeced, it would match the current documentation. Also you don`t need the flag "-Recurse" for "Copy all files to a new folder" as described in the note of example 3. |
Yes, please open a documentation issue for that.
If you want to copy files only, you need to use something like |
This applies if the source path is a directory or at least has directories among the items that a wildcard expression resolves to. For a single directory and file, respectively, it makes sense to create a directory / a file (after all, The current behavior gets messy with multiple source paths, however:
The proposed What was meant to address the above issues was the following suggestion:
To flesh this out a bit:
Given how the current behavior with multiple source items is both useless and obscure, it's hard to imagine that existing code relies on it, which would make this proposal an acceptable Bucket 3: Unlikely Grey Area change. |
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. |
If i want to copy content from a directory without subdirectorys to a NEW folder the Documentations says unter Example 3:
But this only works if under Path ("C:\Logfiles") are subdirectorys.
Steps to reproduce
Expected behavior
Actual behavior
If you create inside C:\logfiles a directory everything works as it should.
Environment data
The text was updated successfully, but these errors were encountered: