![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| |
| 12-27-2006 | #1 (permalink) |
| | Copy-Item Recurse with Wildcard Can you use Copy-Item recursively with a wildcard? Something like: Copy-Item c:\folder\*.txt c:\folder2 -Recurse That's just one of many variations of this. None worked. Using the wildcard is important. I _can_ get a recursive copy to work without wildcards. It should also preserve the folder structure. |
| My System Specs |
| 12-27-2006 | #2 (permalink) |
| | Re: Copy-Item Recurse with Wildcard works for me (and i'm used to working like this now in PoSH ), dir -recurse c:\powershell *.ps1 | copy -destination c:\test -whatif still should work IMHO (at least second example (using provider function) but do only one level : copy c:\powershell\* c:\test -include *.ps1 -rec -whatif copy c:\powershell\* c:\test -filter *.ps1 -rec -whatif guess directories are excluded also then (makes some sence in object terms (directory being just another object, but the filter is provide specific ) still as -filter is provider specific should be able to this while in the filesystem provider i would think. thoughts ? greetings /\/\o\/\/ "Aquinas" <Aquinas@discussions.microsoft.com> wrote in message news:E9104512-96B0-4526-9AEB-88E8A68C6C51@microsoft.com... > Can you use Copy-Item recursively with a wildcard? Something like: > > Copy-Item c:\folder\*.txt c:\folder2 -Recurse > > That's just one of many variations of this. None worked. Using the > wildcard > is important. I _can_ get a recursive copy to work without wildcards. It > should also preserve the folder structure. > |
| My System Specs |
| 12-27-2006 | #3 (permalink) |
| | Re: Copy-Item Recurse with Wildcard "/\/\o\/\/ [MVP]" <mow001@hotmail.NoSpam> wrote in message news:A74D5449-2CC7-4CFE-AF27-466C72ED602B@microsoft.com... > works for me (and i'm used to working like this now in PoSH ), > > dir -recurse c:\powershell *.ps1 | copy -destination c:\test -whatif But that doesn't preserver the directory structure of where the ps1 file was located relative to C:\powershell. -- Keith |
| My System Specs |
| 12-27-2006 | #4 (permalink) |
| | Re: Copy-Item Recurse with Wildcard I'd like to know if it can be done with only the Copy-Item command, and I'd like it to preserve the directory structure. To reiterate, I'm looking to use Copy-Item recursively with a wildcard while preserving the directory structure. The Powershell help doesn't say you can't but doesn't say you can either. Although I think it's implied that it can, or at least I get the impression that it should be doable. After all, it lists -Recurse and -Container as parameter options. It seems odd that I had to end up going to cmd.exe to do a Copy /s to get it done. "/\/\o\/\/ [MVP]" wrote: > works for me (and i'm used to working like this now in PoSH ), > > dir -recurse c:\powershell *.ps1 | copy -destination c:\test -whatif > > still should work IMHO (at least second example (using provider function) > but do only one level : > > copy c:\powershell\* c:\test -include *.ps1 -rec -whatif > copy c:\powershell\* c:\test -filter *.ps1 -rec -whatif > > guess directories are excluded also then (makes some sence in object terms > (directory being just another object, but the filter is provide specific ) > still as -filter is provider specific should be able to this while in the > filesystem provider i would think. > > thoughts ? > > greetings /\/\o\/\/ > > "Aquinas" <Aquinas@discussions.microsoft.com> wrote in message > news:E9104512-96B0-4526-9AEB-88E8A68C6C51@microsoft.com... > > Can you use Copy-Item recursively with a wildcard? Something like: > > > > Copy-Item c:\folder\*.txt c:\folder2 -Recurse > > > > That's just one of many variations of this. None worked. Using the > > wildcard > > is important. I _can_ get a recursive copy to work without wildcards. It > > should also preserve the folder structure. > > > |
| My System Specs |
| 12-28-2006 | #5 (permalink) |
| | Re: Copy-Item Recurse with Wildcard Maybe the following will do what you're trying to achieve. On my machine, this copied all text files in all subdirectories of C:\source and copied them to C:\Dest while preserving the folder structure. copy-item -rec -filter *.txt C:\Source C:\Dest Tom G. -- Aquinas wrote: > I'd like to know if it can be done with only the Copy-Item command, > and I'd like it to preserve the directory structure. To reiterate, > I'm looking to use Copy-Item recursively with a wildcard while > preserving the directory structure. > > The Powershell help doesn't say you can't but doesn't say you can > either. Although I think it's implied that it can, or at least I get > the impression that it should be doable. After all, it lists -Recurse > and -Container as parameter options. > > It seems odd that I had to end up going to cmd.exe to do a Copy /s to > get it done. > > "/\/\o\/\/ [MVP]" wrote: > > > works for me (and i'm used to working like this now in PoSH ), > > > > dir -recurse c:\powershell *.ps1 | copy -destination c:\test -whatif > > > > still should work IMHO (at least second example (using provider > > function) but do only one level : > > > > copy c:\powershell\* c:\test -include *.ps1 -rec -whatif > > copy c:\powershell\* c:\test -filter *.ps1 -rec -whatif > > > > guess directories are excluded also then (makes some sence in > > object terms (directory being just another object, but the filter > > is provide specific ) still as -filter is provider specific should > > be able to this while in the filesystem provider i would think. > > > > thoughts ? > > > > greetings /\/\o\/\/ > > > > "Aquinas" <Aquinas@discussions.microsoft.com> wrote in message > > news:E9104512-96B0-4526-9AEB-88E8A68C6C51@microsoft.com... > > > Can you use Copy-Item recursively with a wildcard? Something like: > > > > > > Copy-Item c:\folder\*.txt c:\folder2 -Recurse > > > > > > That's just one of many variations of this. None worked. Using > > > the wildcard > > > is important. I can get a recursive copy to work without > > > wildcards. It should also preserve the folder structure. > > > > > |
| My System Specs |
| 12-28-2006 | #6 (permalink) |
| | Re: Copy-Item Recurse with Wildcard Yes, that did it! It's the filter option. I guess I was fixated on the -include option, after all, that's what I use when I use get-childitem recursively. thanks. "Tom G." wrote: > Maybe the following will do what you're trying to achieve. On my > machine, this copied all text files in all subdirectories of C:\source > and copied them to C:\Dest while preserving the folder structure. > > copy-item -rec -filter *.txt C:\Source C:\Dest > > Tom G. > -- > > > > Aquinas wrote: > > > I'd like to know if it can be done with only the Copy-Item command, > > and I'd like it to preserve the directory structure. To reiterate, > > I'm looking to use Copy-Item recursively with a wildcard while > > preserving the directory structure. > > > > The Powershell help doesn't say you can't but doesn't say you can > > either. Although I think it's implied that it can, or at least I get > > the impression that it should be doable. After all, it lists -Recurse > > and -Container as parameter options. > > > > It seems odd that I had to end up going to cmd.exe to do a Copy /s to > > get it done. > > > > "/\/\o\/\/ [MVP]" wrote: > > > > > works for me (and i'm used to working like this now in PoSH ), > > > > > > dir -recurse c:\powershell *.ps1 | copy -destination c:\test -whatif > > > > > > still should work IMHO (at least second example (using provider > > > function) but do only one level : > > > > > > copy c:\powershell\* c:\test -include *.ps1 -rec -whatif > > > copy c:\powershell\* c:\test -filter *.ps1 -rec -whatif > > > > > > guess directories are excluded also then (makes some sence in > > > object terms (directory being just another object, but the filter > > > is provide specific ) still as -filter is provider specific should > > > be able to this while in the filesystem provider i would think. > > > > > > thoughts ? > > > > > > greetings /\/\o\/\/ > > > > > > "Aquinas" <Aquinas@discussions.microsoft.com> wrote in message > > > news:E9104512-96B0-4526-9AEB-88E8A68C6C51@microsoft.com... > > > > Can you use Copy-Item recursively with a wildcard? Something like: > > > > > > > > Copy-Item c:\folder\*.txt c:\folder2 -Recurse > > > > > > > > That's just one of many variations of this. None worked. Using > > > > the wildcard > > > > is important. I can get a recursive copy to work without > > > > wildcards. It should also preserve the folder structure. > > > > > > > > |
| My System Specs |
| Thread Tools | |
| |
| Similar topics to: Copy-Item Recurse with Wildcard | ||||
| Thread | Forum | |||
| Re: Remove-Item -recurse still doesn't work? | PowerShell | |||
| "remove-item -recurse" bug! | PowerShell | |||
| Copy-Item : Container cannot be copied onto existing leaf item. | PowerShell | |||
| copy-item changing files attributes on network copy failures | PowerShell | |||
| copy-item -recurse question | PowerShell | |||