回答編集履歴
5
微修正
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
-
指定フォルダのパスに除外フォルダと同名のフォルダが含まれている
|
21
|
+
もし指定フォルダのパスに除外フォルダと同名のフォルダが含まれている場合は以下のようにするとうまくいくかと思います。(`$parent_folder`はフルパスだと仮定します。)
|
22
22
|
|
23
23
|
|
24
24
|
|
4
微修正
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
```PowerShell
|
26
26
|
|
27
|
-
Get-ChildItem $parent_folder -File -Recurse
|
27
|
+
Get-ChildItem $parent_folder -File -Recurse | Where-Object FullName -notlike "$parent_folder*\Online*"
|
28
28
|
|
29
29
|
```
|
30
30
|
|
@@ -84,4 +84,4 @@
|
|
84
84
|
|
85
85
|
```
|
86
86
|
|
87
|
-
複数の除外フォルダ名を指定できます。
|
87
|
+
この例では複数の除外フォルダ名を指定できます。ワイルドカード指定はできません。
|
3
指定パスに除外フォルダ名が含まれている場合の追記
test
CHANGED
@@ -8,9 +8,27 @@
|
|
8
8
|
|
9
9
|
```PowerShell
|
10
10
|
|
11
|
-
Get-ChildItem -File -Recurse | Where-Object FullName -NotLike *\Online*
|
11
|
+
Get-ChildItem $parent_folder -File -Recurse | Where-Object FullName -NotLike *\Online*
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
追記:
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
指定フォルダのパスに除外フォルダと同名のフォルダが含まれているということなので以下のようにするとうまくいくかと思います。(`$parent_folder`はフルパスだと仮定します。)
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```PowerShell
|
26
|
+
|
27
|
+
Get-ChildItem $parent_folder -File -Recurse | Where-Object FullName -notlike "$parent_folder*\Online*"
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
---
|
14
32
|
|
15
33
|
|
16
34
|
|
2
若干の高速化
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
```PowerShell
|
10
10
|
|
11
|
-
Get-ChildItem -File -Recurse | Where-Object FullName -NotLike *\
|
11
|
+
Get-ChildItem -File -Recurse | Where-Object FullName -NotLike *\Online*
|
12
12
|
|
13
13
|
```
|
14
14
|
|
@@ -34,13 +34,15 @@
|
|
34
34
|
|
35
35
|
$temp = [Collections.Generic.List[object]]::new()
|
36
36
|
|
37
|
+
$getChildItem = $ExecutionContext.InvokeProvider.ChildItem.Get
|
38
|
+
|
37
39
|
|
38
40
|
|
39
41
|
while ($stack.Count) {
|
40
42
|
|
41
43
|
$temp.Clear()
|
42
44
|
|
43
|
-
foreach ($item in
|
45
|
+
foreach ($item in $getChildItem.Invoke($stack.Pop(), $false, $false, $true)) {
|
44
46
|
|
45
47
|
if ($item.PSIsContainer) { if ($item.PSChildName -notin $ExcludeDir) { $temp.Add($item.PSPath) } }
|
46
48
|
|
1
微修正
test
CHANGED
@@ -42,7 +42,7 @@
|
|
42
42
|
|
43
43
|
foreach ($item in Get-ChildItem -LiteralPath $stack.Pop()) {
|
44
44
|
|
45
|
-
if ($item.PSIsContainer) { if ($item.Name -notin $ExcludeDir) { $temp.Add($item.PSPath) } }
|
45
|
+
if ($item.PSIsContainer) { if ($item.PSChildName -notin $ExcludeDir) { $temp.Add($item.PSPath) } }
|
46
46
|
|
47
47
|
else { $item }
|
48
48
|
|