源自 : GPT
ps1文件调用
splitF.ps1 文件
param (
$filePath,
$chunkSize,
$outputFolderPath,
$fileName
)
$buffer = New-Object byte[] $chunkSize
$stream = [System.IO.File]::OpenRead($filePath)
try {
$index = 0
while ($stream.Position -lt $stream.Length) {
$file = [System.IO.Path]::Combine($outputFolderPath, "$fileName$index")
$outputStream = [System.IO.File]::OpenWrite($file)
try {
$bytesRead = $stream.Read($buffer, 0, $chunkSize)
$outputStream.Write($buffer, 0, $bytesRead)
}
finally {
$outputStream.Close()
}
$index++
}
}
finally {
$stream.Close()
}
.\splitF.ps1 F:\test/tc.jar 5MB F:\test\ tc
参数1: 文件全路径名
参数2: 每个文件大小
参数3: 输出文件全路径
参数4: 文件名称
函数调用
function splitF {
param (
[string]$filePath,
$chunkSize,
[string]$outputFolderPath,
[string]$fileName
)
$buffer = New-Object byte[] $chunkSize
$stream = [System.IO.File]::OpenRead($filePath)
try {
$index = 0
while ($stream.Position -lt $stream.Length) {
$file = [System.IO.Path]::Combine($outputFolderPath, "$fileName$index")
$outputStream = [System.IO.File]::OpenWrite($file)
try {
$bytesRead = $stream.Read($buffer, 0, $chunkSize)
$outputStream.Write($buffer, 0, $bytesRead)
}
finally {
$outputStream.Close()
}
$index++
}
}
finally {
$stream.Close()
}
}
splitF F:\test/tc.jar 5MB F:\test\ tc
参数1: 文件全路径名
参数2: 每个文件大小
参数3: 输出文件全路径
参数4: 文件名称
linux合成文件
cat splitfiles/* > mergedfile.txt