回答編集履歴

2

修正

2018/03/19 11:46

投稿

Zuishin
Zuishin

スコア28660

test CHANGED
@@ -1,7 +1,11 @@
1
- 以下で
1
+ 以下で条件にマッチするファイルが出力されます。
2
2
 
3
3
  ```
4
4
 
5
5
  $directory = 'c:\bk\'; $from = 201711; $to = 201712; Get-ChildItem $directory | Where-Object { $_ -match "[0-9]+$" -and $Matches[0] -ge $from -and $Matches[0] -le $to }
6
6
 
7
7
  ```
8
+
9
+ 例えばこれを untitled.ps1 というスクリプトに入れるなら `untitled.ps1 | Copy-Item 目的のディレクトリ` という形でコピーできます。
10
+
11
+ これを基にして自分で完成させてください。

1

修正

2018/03/19 11:46

投稿

Zuishin
Zuishin

スコア28660

test CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  ```
4
4
 
5
- $directory = 'c:\bk\'; $from = 201711; $to = 201712; Get-ChildItem $directory | Foreach-Object { if ($_ -match "[0-9]+$" -and $Matches[0] -ge $from -and $Matches[0] -le $to) { $_ } }
5
+ $directory = 'c:\bk\'; $from = 201711; $to = 201712; Get-ChildItem $directory | Where-Object { $_ -match "[0-9]+$" -and $Matches[0] -ge $from -and $Matches[0] -le $to }
6
6
 
7
7
  ```