Пупкин_Василий Asked:2021-11-03 13:20:47 +0000 UTC2021-11-03 13:20:47 +0000 UTC 2021-11-03 13:20:47 +0000 UTC Powershell 将数组拆分为小文件 772 我有一个这样的数组: string1 string2 string3 ... string100 有必要用这些行创建文本文件,在每个文件中,例如 10 行。不知道怎么做? powershell 1 个回答 Voted Best Answer Julia Jose 2021-11-03T14:11:49Z2021-11-03T14:11:49Z $arr = @() $groupByCount = 7; $rootFileScripts = "D:\scripts\"; $fileRootName = "defaultLogOutput"; $fileExtension = ".txt"; for($index = 0; $index -lt $arr.length; $index += $groupByCount) { for ($jIndex = 0; $jIndex -lt $groupByCount; $jIndex++) { $fileName = $rootFileScripts + $fileRootName + $index + $fileExtension; echo $arr[$index+$jIndex] | Out-File $fileName -Append; } }
1 个回答