I want to move n random files from m files in a folder to subfolders. so the final output needs to be some x folders each containing n files. the folder name can be random.
Please help to find a way.
I tried the below PowerShell script and it is creating only empty folders
$filesperfolder = 5000
$sourcePath = "D:\source"
$destPath = "E:\Dest"
$i = 0;
$folderNum = 1;
Get-ChildItem "$sourcePath\*.jpg" | % {
New-Item -Path ($destPath + "\" + $folderNum) -Type Directory -Force
Move-Item $_ ($destPath + "\" + $folderNum);
$i++;
if ($i -eq $filesperfolder){
$folderNum++;
$i = 0 ;
}
}