quoted form of the POSIX path & drag n drop
This is how I do it:
on open (dragged_items)
my handle Files(draggeditems)
end open
on handle Files(theseitems)
set the item_sizecheck to the quoted form of the POSIX path of these_items
do shell script ("du -sk " & item_sizecheck & " | awk '{print $1}'")
set x to the result
set destination to "/Volumes/basti"
do shell script ("df -k " & destination & " | xargs echo | awk '{print $11}'")
set y to the result
if x ≤ y then
display dialog "space there"
end if
if x ≥ y then
display dialog "no space"
end if
end handle_Files
Of course in the orininal script instead of displaying a dialog that there is enough space the script will simply copy the files.
The problem now is that I can't get the "quoted form of the POSIX path" for many items at the same time (let's say I want to copy 3 things simultaniously).
So I think I have to cycle through the items (set this_item to item i of these_items),but then I have a problem:
I think checking the filesize/discsize is easiest done by the simple equasion (x larger than y),but if i do this for many objekts i have to use a unknown number of variables.
example:
x1 would be the first of the 3 items I draged onto my application,x2 is the second and x3 the third (...)
Then I would have to add up the filesizes of all these items using du,and then compare it to the available disc space ((x1 x2x3) greater than y).
How do I do this?
iMac G3, Mac OS X (10.3.9), 500 Mhz, 768 Mb Ram, 18Mb VRAM, 120 GB HD