Re: Folder Size Applescript
Re: Folder Size Applescript
- Subject: Re: Folder Size Applescript
- From: "Adam Bell" <email@hidden>
- Date: Sat, 29 Apr 2006 12:22:24 -0300
On my Tiger machine they go like this:
0 = none
1 = Orange
2 = Red
3 = Yellow
4 = Blue
5 = Indigo
6 = Green
7 = Grey
In the contextual menu they are in spectral order: None, then: Red; Orange; Yellow; Green; Blue; Indigo; then Grey instead of Violet.
Thanks for the fix for other colors (although Red is an index of 2), however.
Adam
On 4/29/06, Gary (Lists) <
email@hidden> wrote:> On 4/28/06, Joseph White <
email@hidden> wrote:
>>
>> Hello,
>> I am a recent switcher and have just discovered AppleScripts. I have
>> been trying to educate myself a little on using these scripts, it is
>> a little difficult because I have no coding experience whatsoever.
>> I would like to wright a script that would allow me label a folder
>> with a certain color when the folder reaches a certain size.
>> For example...in my podcast folder I have many subfolders of the
>> various podcasts that I subscribe to. Once these subfolders reach
>> 700 MB I want to burn them on a CD and remove them from my hard
>> drive. Since I subscribe to many podcasts, it is a laborious task to
>> go searching through each subfolder looking for the ones that are
>> large enough to burn onto a CD. Therefore it would be very nice, I
>> think, to have a script to search through all of the subfoders
>> located in my podcast folder and color label only those subfolders
>> that are the appropriate size.
>> If anyone knows a script that would allow me to do this, or if
>> someone could point me in the right direction I would appreciate it.
>> Thank you in advance.
>> --JB
"Adam Bell" top-posted-but-I-totally-fixed-it-for-him-because-hes-swell:
> Something like this (which given the hour, I haven't checked thoroughly) will
> set the color label of any folder in PodCasts whose size is greater than 600
> MB to red:
>
> on adding folder items to PodCasts after receiving theCasts
> tell application "Finder"
> set fldrs to folders of (PodCasts as alias) as alias list
> repeat with aFolder in fldrs
> if ((size of (info for aFolder)) div 1048576) > 600 then set label
> index of aFolder to 2
> end repeat
> end tell
> end adding folder items to
>
> (*
> In the AppleScript Utility,
> - click "Setup Actions". In the dialog,
> - click "Enable Folder Actions".
> - click the plus sign on the column labeled "Folders With Actions". Choose
> your podCasts folder and click Open.
> - in the dropdown box, choose the script that you just saved. Click Attach. -
> close the AppleScript Utility.
> *)
And here is a handler that will fit in with your work.
I am using X.3.9, and in this Finder version, the label numbers do not match
the order they are shown in the label contextual menu. You may have noted
this yourself. This handler helps correct that.
(* -- Tested: OS X.3.9
FIX LABEL INDEX -- LEFT-TO-RIGHT-COLOR (PRIORITY)
0 - none -- 0
1 - second color, from left -- 2
2 - first color, on left -- 1
3 - third color, from left -- 3
4 - fifth, from left -- 5
5 - sixth, from left -- 6
6 - fourth, from left -- 4
7 - seventh, from left -- 7
*)
to FinderLabel(i, n)
-- i is the item alias/file spec, n is the priority number (0..7)
-- Re-map given priority to finder's screwy label numbers
-- so that the colors are number, L-to-R, 0-to-7
-- 0 is ok
if (n = 1) then set n to 2
if (n = 2) then set n to 1
-- 3 is ok
if (n = 4) then set n to 6
if (n = 5) then set n to 4
if (n = 6) then set n to 5
try
tell application "Finder" to set label index of i to n
return true
on error
return false
end try
end FinderLabel
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden