Auto putting files in folders
-
- Posts: 22
- Joined: 05 May 2017 15:16
Auto putting files in folders
I have around 1000 files in folder. I want to divide those files and put them in 50 folders , 20 images in each new folder. How i can do that?
Re: Auto putting files in folders
By scripting it
E.g.:
E.g.:
Code: Select all
$batch = 20; // How many items to put in a folder
$folderName = "Images-"; // This name will be extended by the script!
// ========================================================================
// == DO NOT CHANGE ANYTHING BELOW IF YOU DO NOT KNOW WHAT YOU ARE DOING ==
// ========================================================================
$items = <get SelectedItemsPathNames <crlf>>;
end !$items, "No items selected, aborted!";
$count = gettoken($items, "count", <crlf>);
$loops = ($count % $batch) ? ceil($count / $batch) : $count / $batch;
while ($i++ < $loops) {
$newFolder = $folderName . (($loops <= 99) ? format($i, "00") : format($i, "000"));
$blockOfItems = gettoken($items, $batch, <crlf>, , 1);
$items = gettoken($items, $batch + 1, <crlf>, , 2);
moveto $newFolder, replace($blockOfItems, <crlf>, "|"), , 2, 2;
}
One of my scripts helped you out? Please donate via Paypal