I need to copy a large number of files to the backup folder, but I want to save their relative paths. I need only certain files; i.e.
C:\scripts\folder\File.ext1 C:\scripts\folder2\file2.ext2 C:\scripts\file3.ext1
But I only need to copy the ext1 files like this:
C:\backup\folder\File.ext1.bak C:\backup\file3.ext1.bak
The source paths have several depths. This is what I have to copy the files:
$files = gci -path C:\scripts\ -recurse -include *.ext1 $files | % { Copy-Item $_ "$($_).bak"; move-item $_ -destination C:\backup\ }
It just flushes all the files in C: \ backup \ and no path appears. Not sure how this part will be done.
Mrgrant
source share