Hi,
I would like to know if the handler below consumes a lot of cpu-resources.
What the script does:
-receives a very long list of items (generally images, like tif, jpg, png) up to 500
-it calculates the amount of items/mb to fill a CD/DVD if near to the total capacity of a CD/DVD
-creates a new list and a new burn-folder for files exceeding the capacity of a CD/DVD
Tell me your meaning, thanks.
--some initial values to get started
set burn_f to ((path to pictures folder as text) & "Backup:" as text)
set vmdd to "CD"
set nm_cat to "Test"
-->set myfile to list of files
my import_files(myfile, nm_cat, vmdd, burn_f)
on import_files(myfile, nm_cat, vmdd, burn_f)
--create multiple burn-folders if needed
set burn_trg to nm_cat & "-" & vmdd & " 1" & ".fpbf"
set flnr to 1
set Cap_mb to 0
local myfile
local flnr
local burn_trg
if vmdd is "DVD" then
set {minsz, maxsz} to {4670, 4690}
else
set {minsz, maxsz} to {670, 690}
end if
--get burn-folder
set burn_trg to alias (nm_cat & "-" & vmdd & " " & flnr & ".fpbf" as text)
tell application "Finder"
--sort items in groups
set dd to 0
repeat with i in myfile
set dd to dd + 1
set fsz to (size of i) / 1024 / 1024 as integer
if fsz = 0 then
set fsz to (size of i) / 1024 as integer
end if
--sum results
set Cap_mb to Cap_mb + fsz
if Cap_mb ≥ minsz and Cap_mb < maxsz then
make new alias file of alias burn_trg to i
--generate the next burn folder list
copy items dd thru -1 of myfile to myfile
set flnr to flnr + 1
--create a new burn folder
set new_fnm to (nm_cat & "-" & vmdd & " " & flnr & ".fpbf" as text)
set burn_trg to (burn_f & new_fnm as text)
make new folder at burn_f with properties {name:new_fnm}
--reset mb counter
set Cap_mb to 0
else
make new alias file of alias burn_trg to i
end if
end repeat
--burn folders now
reveal alias burn_f
end tell
end import_files