2014-02-19 21 views
1

我想列出這個腳本只找到10000個第一個文件,但我找不到一個方法使它工作。 腳本是這樣的:使一個P​​owershell腳本只需要找到這個過濾器定義的第一個10000個文件

$totalList = @() 
Get-Item 'D:\tempfolder\*\' | % { 
    $dir = $_.FullName 
    $list = Get-ChildItem $dir -recurse *.zip | sort modifyTime -desc | select -skip 2 
    $totalList = $totalList + $list; 
} 

$totalList = $totalList -take 10000 

如預期的那樣-Take 1000不能正常工作,所以我怎麼可以定義多個文件應該找到最大?

+3

你可以嘗試$ totalList = $ totalList |選擇 - 首先10000 –

+0

已經嘗試,但你不能管。謝謝 – RayofCommand

+0

對不起,它的工作原理。但只有當我輸出文件中的輸出。奇怪。 – RayofCommand

回答

3

你可以說:

$totalList = $totalList[0..9999] 
+0

也適用,但我必須將輸出導出爲.csv或其他內容。它不會顯示在我的外殼中。謝謝 – RayofCommand

相關問題