Skip to content

Instantly share code, notes, and snippets.

@Szeraax
Last active December 7, 2017 19:35
Show Gist options
  • Save Szeraax/82c49ec9f0b97e648d84e794569d1738 to your computer and use it in GitHub Desktop.
Save Szeraax/82c49ec9f0b97e648d84e794569d1738 to your computer and use it in GitHub Desktop.
$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