Last active
December 7, 2017 19:35
-
-
Save Szeraax/82c49ec9f0b97e648d84e794569d1738 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$filesperfolder = 55 | |
$sourcePath = "C:\Source\SPLITFILELOCATION\" | |
$destPath = "C:\Source\Test Sample\" | |
$i = 0; | |
$FolderName = "Dr. Bob" | |
$folderNum = 1; | |
$CurrentFolderSize = 0 | |
New-Item -Path ($destPath + $FolderName + $folderNum) -Type Directory -Force | |
Get-ChildItem "$sourcePath\*.pdf " | % { | |
if (($CurrentFolderSize + $_.Length) -gt 800MB) { | |
$folderNum++; | |
$CurrentFolderSize = 0 | |
New-Item -Path ($destPath + $FolderName + $folderNum) -Type Directory -Force | |
} | |
$CurrentFolderSize += $_.Length | |
Move-Item $_ ($destPath + $FolderName + $folderNum) | |
$i++; | |
if ($i -eq $filesperfolder){ | |
$folderNum++; | |
New-Item -Path ($destPath + $FolderName + $folderNum) -Type Directory -Force | |
$i = 0 ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment