Re: Filling disks efficiently
Re: Filling disks efficiently
- Subject: Re: Filling disks efficiently
- From: Chris Adams <email@hidden>
- Date: Tue, 23 Oct 2001 14:05:34 +0000
On 10/22/01 5:43 PM as digestion wrote:
>
Hi:
>
>
I have a need to burn a dozen, to 4 dozen, files at a time to CDs on a
>
regular basis. Files range from 50mb to 600mb in size.
>
>
I would like to write a script that looks at the file sizes, and then writes
>
me a list of what files to burn to the same disk, so that a minimum number
>
of CDs are used. (Hmmm, starting to sound like a "story problem"....)
>
>
If anyone can clue me in as to the best logic strategy for this, I would
>
appreciate it. Is there a general phrase that describes this type of
>
problem?
>
>
Thanks in advance,
>
>
asd
>
This is the applescript command that can save a lot of headaches:
set totalsize to (size of selection)
set totalsizekb to totalsize / 1000 as real
-- totalsize gives the size in bytes, totalsizekb in KB
SInce this is relatively small (dozens instead of thousands of files) brute
force/recursion could work well. I would do it this way (copy and paste
into the script editor and code away!):
-- put all of the files that you want to burn into sourceFolder
-- you could add an error trap to move all files larger than 655MB
-- to a "too big" folder.
-- you will create subfolders with a couter so that they will be named
-- "disk 1", "disk 2", "disk 3"
tell application "Finder"
set sourceFolder to (choose folder with prompt "Select the Source
Folder")
set MaxDiskSize to 6.55E+8 -- 655000000 for CD, in Bytes
set folderCounter to 1
set tempFolderName to "disk " & folderCounter
-- build the first folder
-- set newFolderSize to 0
set newFolder to (make new folder in sourceFolder with properties
{name:tempFolderName})
set sourceFolderFiles to every file of sourceFolder
repeat with eachFile in sourceFolderFiles
-- select eachFile
set fileSize to (size of eachFile)
set fileName to (name of eachFile)
-- @@@@
-- display dialog "fileName - " & fileName & return
-- @@@@
-- this loops through all of the open folders to see if the
-- file will fit. if not, it will build a new folder and
-- move the file to the new folder
set isItMoved to false -- this is a flag
set sourceFolderFolders to every folder of sourceFolder
repeat with eachFolder in sourceFolderFolders
set folderSize to (size of eachFolder)
if fileSize + folderSize < MaxDiskSize then
move eachFile to eachFolder
set isItMoved to true
exit repeat
end if
end repeat -- ends folder repeat
if isItMoved = false then
-- create new folder
set folderCounter to folderCounter + 1
set tempFolderName to "disk " & folderCounter
set newFolder to (make new folder in sourceFolder with
properties {name:tempFolderName})
move eachFile to newFolder
set isItMoved to true
end if
end repeat -- ends file repeat
end tell -- ends tell finder
-- end script
Also, this script automates Toast to burn CD's from a folder:
http://www.cypresslakestudios.com/applescript/index.html#backupToCD
Hope this helps.
--
Chris Adams
Cypress Lake Studios
Hypermedia, Quicktime, and Internet Design
http://www.cypresslakestudios.com
email@hidden