I found solutions, but this solutions don't exclude the content of the subdirectories excluded.
I want copy recursively a directory to another location, but excluding the subdirectory "Videos" and its content. The next command finish, but no exclude the subdirectory "Videos" and its content.
# PowerShell version: 4.0
# This command copy recursively the directory "J:\All" to "J:\Users\John\Desktop\my_backup", excluding "J:\All\Videos"
Copy-Item -Recurse -Path ("J:\All" | ? { $_.FullName -NotMatch ("^J:\\All\\Videos") }) "J:\Users\John\Desktop\my_backup"
Thank you!
RoboCopy is a better solution here. See https://superuser.com/questions/482112/using-robocopy-and-excluding-multiple-directories
robocopy J:\All J:\Users\John\Desktop\my_backup /MIR /XD j:\all\videos
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments