-2

如果子目录包含“connect.txt”,则复制目录我只想将多个目录从一个位置复制到另一个位置,前提是这些目录的任何子目录中都包含 connect.txt 文件。

例子:

C:\ANIMAL\DOG\CONNECT.TXT
C:\PLANET\EARTH\CONNECT.TXT
C:\SYSTEM\USER\ADMIN.TXT

然后我只想将 ANIMAL & PLANET 目录复制到 C:\DESKTOP。

输入 :

C:\ANIMAL\TIGER\CONNECT.TXT
C:\ANIMAL\LION\WILD.TXT
C:\PLANET\EARTH\CONNECT.TXT
C:\SYSTEM\USER\ADMIN.TXT
C:\SYSTEM\USER\DOG.TXT
C:\SYSTEM\USER\CAT.TXT

输出:

C:\DESKTOP\ANIMAL
C:\DESKTOP\EARTH
4

1 回答 1

0

也许像

powershell.exe -executionpolicy unrestricted -encodedCommand RwBlAHQALQBDAGgAaQBsAGQASQB0AGUAbQAgAC0AUABhAHQAaAAgACcAQwA6AFwAJwAgAC0ARgBpAGwAdABlAHIAIAAnAEMAbwBuAG4AZQBjAHQALgB0AHgAdAAnACAALQBSAGUAYwB1AHIAcwBlACAALQBFAHIAcgBvAHIAQQBjAHQAaQBvAG4AOgBJAGcAbgBvAHIAZQAgAC0ARQB4AGMAbAB1AGQAZQAgACcAQwA6AFwARABlAHMAawB0AG8AcABcACoAJwAgAHwAIABGAG8AcgBFAGEAYwBoAC0ATwBiAGoAZQBjAHQAIAB7ACQAXwAuAEQAaQByAGUAYwB0AG8AcgB5AH0AIAB8ACAAQwBvAHAAeQAtAEkAdABlAG0AIAAtAEQAZQBzAHQAaQBuAGEAdABpAG8AbgAgACcAQwA6AFwARABlAHMAawB0AG8AcABcACcAIAAtAEMAbwBuAHQAYQBpAG4AZQByACAALQBGAG8AcgBjAGUAIAAtAFIAZQBjAHUAcgBzAGUAIAAtAEMAbwBuAGYAaQByAG0AOgAkAGYAYQBsAHMAZQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuADoASQBnAG4AbwByAGUA

而以下的编码命令代表:

Get-ChildItem -Path 'C:\' -Filter 'Connect.txt' -Recurse -ErrorAction:Ignore -Exclude 'C:\Desktop\*' | ForEach-Object {$_.Directory} | Copy-Item -Destination 'C:\Desktop\' -Container -Force -Recurse -Confirm:$false -ErrorAction:Ignore

(但不要相信我,将上面的字符复制到 base64 到文本在线转换器中,自己看看!)

于 2019-06-11T22:33:15.270 回答