help on a script regulating folder size please
help on a script regulating folder size please
- Subject: help on a script regulating folder size please
- From: Kate Brooks <email@hidden>
- Date: Tue, 30 Mar 2004 11:48:32 -0800
Hello,
I've just joined this list because I'm working on a small script to
control the folder size of a shared folder in an office environment.
We want to regulate the size of a shared folder so that once it
reaches ~650 MB the users will be prompted to start a new folder (the
idea is that once each folder reaches the capacity of a cd a new
shared folder will be started and the contents of the original will
be archived to a cd).
I've resorted to an add item folder action that generates an alert
showing the folder size, but I'm unhappy because the folder size
displays in bytes rather than KB or MB & most people find bytes
confusing.
What we originally wanted was to set a maximum folder size that would
refuse any new item once the folder reached 650 MB (like a
partitioned disk would), but we've resorted to adapting an existing
folder action script which generates an alert telling the user the
current folder size.
Since our goal is to find a way of controlling the addition of items
to a folder once it has reached a given size we don't really care
whether the script generates an alert, or merely refuses to add
items, but it does have to be easily understood by the average office
user (& a report of folder size in bytes is not easily understood).
I've pasted (see below) a copy of the script we're currently working
on & we're looking for any suggestions on the following issues for a
script on OS X systems:
1. any way to set a maximum folder size so that it would simply
refuse to allow a user adding items that would go beyond its maximum
folder size?
2. any way to display folder size information in MBs (or @ least in
KB) instead of bytes?
3. what is the syntax for setting a contingent so that the alert
would only display if folder size is greater than a given size (eg:
300 MB)
I've tried adding the following to generate an alert for a folder
greater than 300 MB:
on adding folder items to this_folder
get the size of this_folder
if the size of this_folder is greater than 300000000 then
tell application "Finder" ...
But this resulted in an error -1728 when executing the script
4. general info ... is it better to have 2 separate scripts for
different folder actions or one script that includes several handlers
eg: one for an open folder & one for adding item?
ie: on open folder -- alert display folder size
on adding folder -- alert display folder size
thank you,
Kate Brooks
PS - the final script will be for OS X but I'm working at home this
week on OS 9 so the following script is for OS9
~~~~~~~~~~~~~~~
This script is adapted from the standard OPEN - SHOW COMMENTS IN
DIALOG script by Sal Soghoian )1998 Apple Computer.
property dialog_timeout : 30 -- set the amount of time before dialogs
auto-answer.
on adding folder items to this_folder
tell application "Finder"
activate
set the alert_message to the size of this_folder
if the alert_message is not "" then
set the user_choice to my
notify_the_front_application(alert_message, {"Open Comments",
"Cancel", "OK"}, 3, dialog_timeout, "", false)
if the user_choice is "Open Comments" then
open information window of this_folder
end if
end if
end tell
end opening folder
-- STANDARD FOLDER ACTIONS VERISON
on notify_the_front_application(alert_message, button_list,
default_button_name_or_index, dialog_timeout, icon_index,
beep_indicator)
set the alert_message to "The current size of this folder
is:" & return & return & the alert_message
if the button_list is "" then set the button_list to {"Cancel", "Stop"}
if default_button_name_or_index is "" then set
default_button_name_or_index to the number of items in the button_list
tell application (path to frontmost application as text)
if the beep_indicator is true then beep
try
if the icon_index is "" then
display dialog alert_message buttons
button_list default button default_button_name_or_index giving up
after dialog_timeout
else
display dialog alert_message buttons
button_list default button default_button_name_or_index with icon
icon_index giving up after dialog_timeout
end if
set the user_choice to the button returned of
the result
on error
-- a Cancel button was passed in the button
list and chosen by the user
set the user_choice to "Cancel"
end try
return the user_choice
end tell
end notify_the_front_application
~~~~~~~~~~~~~~~~
--
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Kate Brooks
mailto:email@hidden
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.