I am trying to copy all .pdf files from all folders and sub folder (dirs. and subdirs).
First I used
$source = "c:\Folder1\"
$desti = "D:\foderA\"
PS> Get-ChildItem -recurse $source -Filter "*.pdf"
It displays all the files for dir and sub dir but when I try to use copy-Item I get error.
PS> Get-ChildItem -recurse $source -Filter "*.pdf" | % {Copy-Item $_ -destination $desti}
Error: Copy-Item : Cannot find path 'H:\Folder1\Folder2\..\.. because it does not exist
What am I doing wrong?
First I used
$source = "c:\Folder1\"
$desti = "D:\foderA\"
PS> Get-ChildItem -recurse $source -Filter "*.pdf"
It displays all the files for dir and sub dir but when I try to use copy-Item I get error.
PS> Get-ChildItem -recurse $source -Filter "*.pdf" | % {Copy-Item $_ -destination $desti}
Error: Copy-Item : Cannot find path 'H:\Folder1\Folder2\..\.. because it does not exist
What am I doing wrong?
Last edited: