gpt4 book ai didi

powershell - 以递归方式复制不包含子目录及其内容的目录

转载 作者:行者123 更新时间:2023-12-03 01:18:16 25 4
gpt4 key购买 nike

我找到了解决方案,但此解决方案并未排除排除的子目录的内容。

我想将目录递归复制到另一个位置,但不包括子目录“视频”及其内容。
下一条命令完成,但不排除子目录“视频”及其内容。

# 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"

谢谢!

最佳答案

RoboCopy是一个更好的解决方案。参见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

关于powershell - 以递归方式复制不包含子目录及其内容的目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23495588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com