Skip to content

Instantly share code, notes, and snippets.

@awayken
Created June 25, 2013 20:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save awayken/5861923 to your computer and use it in GitHub Desktop.
Save awayken/5861923 to your computer and use it in GitHub Desktop.
Split files using Powershell, modified from: http://stackoverflow.com/a/11010158/215200
# Modified from: http://stackoverflow.com/a/11010158/215200
$fromFolder = "D:\FOLDER\"
$rootName = "FILENAME"
$ext = "EXT"
$from = "{0}{1}.{2}" -f ($fromFolder, $rootName, $ext)
$fromFile = [io.file]::OpenRead($from)
$upperBound = 100MB
$buff = new-object byte[] $upperBound
$count = $idx = 0
try {
"Splitting $from using $upperBound bytes per file."
do {
$count = $fromFile.Read($buff, 0, $buff.Length)
if ($count -gt 0) {
$to = "{0}{1}.{2}.{3}" -f ($fromFolder, $rootName, $idx, $ext)
$toFile = [io.file]::OpenWrite($to)
try {
"Writing to $to"
$tofile.Write($buff, 0, $count)
} finally {
$tofile.Close()
}
}
$idx ++
} while ($count -gt 0)
}
finally {
$fromFile.Close()
}
@Emilieganouch
Copy link

Bonjour,
Serait-il possible d'adapter ce script afin de récupérer l’entête sur chaque fichier découper ?

Merci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment