Chunking a large folder into smaller folders

I have looking for a good script that will span a large folder into many smaller folder to fit on CDs or even DVDs. This topic I am sure has been descused I just can not find a script that works with 10.3

Please help. It would be a true live saver. Thanks Darren

Here’s a slightly modified version of a script I posted in this thread:

set max_size to (640 * (1024 ^ 2)) --640 MBs
set subfolder_prefix to "subfolder "

tell application "Finder"
	activate
	set the_folder to (choose folder) as alias
	set {i, j, the_contents} to {0, 1, (items of the_folder)}
	set new_folder to make new folder at the_folder with properties {name:(subfolder_prefix & (j as string))}
	repeat with This_Item in the_contents
		if folder of This_Item = true then
			try
				set the_size to physical size of This_Item
			on error
				set the_size to size of This_Item
			end try
		else
			set the_size to size of This_Item
		end if
		if (i + the_size) < max_size then
			set i to (i + the_size)
			move This_Item to new_folder
		else
			set {i, j} to {the_size, (j + 1)}
			set new_folder to make new folder at the_folder with properties {name:(subfolder_prefix & (j as string))}
			move This_Item to new_folder
		end if
	end repeat
	beep
	display dialog (((count of the_contents) as string) & " items split into " & (j as string) & " subfolders.") buttons {"OK"} default button 1 with icon 1 giving up after 10
end tell

Jon

The script above won’t optimize the subfolders to make them as close to the target size but, depending on the size of the contents of your source folder that may not be much of an issue. In other words, if you have lots of small files of about 1 MB each, then you’ll be very close. If your files are 20 MB each, then you may be off by 19 MB or more but that’s not too bad either. The real problem is if you have subfolders of about 325 MB each. In this case, this script won’t optimize the folder at all since 2 folders would be more than the max size and not combined. Still, in a fix, and for most cases, it should work well.

Jon

I tried the script by attaching it to a folder and it did not work. It did nothing. Did I do something wrong?

Just copy the script to the Script Editor and press run. Then choose the folder you want to split. This script is not a good candidate for a folder action, at least not in its present form.

Jon