Franklin0 commited on
Commit
87cb52f
·
verified ·
1 Parent(s): 2743cb6

Upload chunking.ps1 with huggingface_hub

Browse files
Files changed (1) hide show
  1. chunking.ps1 +41 -0
chunking.ps1 ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration
2
+ $sourceDir = ".\multiview_rgb_vids"
3
+ $chunkSizeInGB = 40
4
+ $chunkSizeBytes = [int64]$chunkSizeInGB * 1024 * 1024 * 1024
5
+ $bufferSize = 1MB
6
+
7
+ # Get all large tar.gz files
8
+ $files = Get-ChildItem -Path $sourceDir -Filter "*.tar.gz"
9
+
10
+ foreach ($file in $files) {
11
+ Write-Host "Processing: $($file.Name) ($([Math]::Round($file.Length / 1GB, 2)) GB)" -ForegroundColor Cyan
12
+
13
+ $fileStream = [System.IO.File]::OpenRead($file.FullName)
14
+ $chunkIndex = 0
15
+
16
+ try {
17
+ while ($fileStream.Position -lt $fileStream.Length) {
18
+ $chunkFileName = "$($file.FullName).part_$($chunkIndex.ToString('D2'))"
19
+ Write-Host " Creating chunk: $(Split-Path $chunkFileName -Leaf)" -ForegroundColor Gray
20
+
21
+ $chunkStream = [System.IO.File]::Create($chunkFileName)
22
+ $bytesRemaining = $chunkSizeBytes
23
+ $buffer = New-Object Byte[] $bufferSize
24
+
25
+ while ($bytesRemaining -gt 0 -and $fileStream.Position -lt $fileStream.Length) {
26
+ $bytesToRead = [Math]::Min($bufferSize, $bytesRemaining)
27
+ $bytesRead = $fileStream.Read($buffer, 0, $bytesToRead)
28
+ $chunkStream.Write($buffer, 0, $bytesRead)
29
+ $bytesRemaining -= $bytesRead
30
+ }
31
+
32
+ $chunkStream.Close()
33
+ $chunkIndex++
34
+ }
35
+ }
36
+ finally {
37
+ $fileStream.Close()
38
+ }
39
+
40
+ Write-Host "Finished splitting $($file.Name)`n" -ForegroundColor Green
41
+ }