Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Bug in copying file shares?

Reply
 
Old 08-25-2008   #1 (permalink)
Jonathan Allen


 
 

Bug in copying file shares?

If I try to copy a folder share then it creates a new directory one level
lower than I expected. In this example, I want to copy the contents into
".../SysInternals" but it creates ".../SysInternals/Tools" instead.

PS C:\> copy-item "\\live.sysinternals.com\Tools" -destination "C:\Program
Files\SysInternals" -recurse -force -whatIf

What if: Performing operation "Copy Directory" on Target "Item:
\\live.sysinternals.com\Tools Destination: C:\Program Fi
les\SysInternals\Tools".

If I try again using a sub folder of the file share, then it works as I
expected:

PS C:\> copy-item "\\live.sysinternals.com\Tools\WindowsInternals"
-destination "C:\Program Files\SysInternals" -recurse -force -whatIf

What if: Performing operation "Copy Directory" on Target "Item:
\\live.sysinternals.com\Tools\WindowsInternals Destinati
on: C:\Program Files\SysInternals\WindowsInternals".


Is this a bug or am I missing something?

And either way, is there an easy way to get the effect I'm after?

--
Jonathan Allen

My System SpecsSystem Spec
Old 08-25-2008   #2 (permalink)
Kiron


 
 

RE: Bug in copying file shares?

Here is an old thread that explains this bug/feature and the function 'xCopy'
--now renamed 'ezCopy'-- was introduced:
http://groups.google.com/group/micro...9b8b4424c2af22

# ezCopy checks for the presence of the
# destination folder and proceeds accordingly

function ezCopy (
[string]$src = $(throw 'Specify the source directory'),
[string]$dest = $(throw 'Specify the destination diirectory')
) {
$src = $src -replace '\*$'
if (test-path $dest) {
switch -regex ($src) {
'\\$' {$src = "$src*"; break}
'\w$' {$src = "$src\*"; break}
default {break}
}
}
copy-item $src $dest -recurse -force
}

# then...
ezCopy \\live.sysinternals.com\Tools 'C:\Program Files\SysInternals'

--
Kiron
My System SpecsSystem Spec
Old 08-25-2008   #3 (permalink)
Mohan Gupta


 
 

RE: Bug in copying file shares?

How about


PS C:\> copy-item "\\live.sysinternals.com\Tools\*" "C:\Program
Files\SysInternals" -recurse -force -whatif

Does that work?
My System SpecsSystem Spec
Old 08-25-2008   #4 (permalink)
Jonathan Allen


 
 

RE: Bug in copying file shares?

When I used *.* it didn't get sub-directories even though I specified
-recurse. If I think of it I will try just * tomorrow.

--
Jonathan Allen


"Mohan Gupta" wrote:
Quote:

> How about
>
>
> PS C:\> copy-item "\\live.sysinternals.com\Tools\*" "C:\Program
> Files\SysInternals" -recurse -force -whatif
>
> Does that work?
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
One resolution to Slow Vista copying times from network shares Vista networking & sharing
VPN connects, but no file shares Vista networking & sharing
VPN connects, but no file shares Vista networking & sharing
WMDC Changes File Date When copying file to Laptop Vista General
Copying on network shares stutters Vista Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46