Re: AppleScript-Users Digest, Vol 8, Issue 149
Re: AppleScript-Users Digest, Vol 8, Issue 149
- Subject: Re: AppleScript-Users Digest, Vol 8, Issue 149
- From: James Roberts <email@hidden>
- Date: Thu, 31 Mar 2011 20:27:12 -0400
On 31-03-2011, at 18:50 , email@hidden wrote:
> Hey James,
>
> I made minor modifications to your script, and it works fine for me on 10.6.7. (System Events groks file extensions better than the Finder these days.)
>
> (* Set Lable Index colours of selected files to defaults *)
> set fileColorList to {red:{"app", "scpt", "bin", "pl", "py", "sh"}, orange:{"zip", "mpkg", "pkg", "tgz", "gz", "dmg", "torrent", "iso", "tar"}, yellow:{"xml", "xpi", "html", "htm", "PrefPane"}, green:{"aa", "m3u", "mp3", "mp4", "mov", "xspf", "qt", "aif", "aiff"}, blue:{"epub", "pdf", "txt", "rtf", "asc", "ascii", "djvu", "old"}, purple:{"pages", "numbers", "keynote", "doc", "xls", "nbp", "csv", "ics", "ppt", "pps"}, grey:{"png", "jpg", "jpeg", "gif", "tif", "tiff", "psd"}}
>
> set theseFiles to choose file with multiple selections allowed
>
> repeat with myFile in theseFiles
> tell application "System Events" to set fileExt to name extension of myFile
> tell application "Finder"
> if fileExt is in orange of fileColorList then
> set label index of myFile to 1
> else if fileExt is in red of fileColorList then
> set label index of myFile to 2
> else if fileExt is in yellow of fileColorList then
> set label index of myFile to 3
> else if fileExt is in blue of fileColorList then
> set label index of myFile to 4
> else if fileExt is in purple of fileColorList then
> set label index of myFile to 5
> else if fileExt is in green of fileColorList then
> set label index of myFile to 6
> else if fileExt is in grey of fileColorList then
> set label index of myFile to 7
> end if
> end tell
> end repeat
>
> You're not trying to change attributes of System applications or apps downloaded from the App-Store are you?
>
> BTW: I wouldn't run this using a 'choose file' dialog; I'd use FastScripts and bind it to a Finder-specific keyboard shortcut. And in fact I have a couple of scripts which do just that. It's simpler and faster (for me).
>
> --
> Best Regards,
> Chris
That works better. My extra get seems to be what was generating the security errors. I didn’t understand that all the file info was passed with the choose and thought I had to request it for each file. What are the advantages of placing the repeat outside the tell statement.
Not trying to change system files just tidy up downloads and tmp. Will google FastScripts, I’m not familiar with it. Applescript is driving nuts, there seems to be endless variations of how things work.
Thanks again Chris. _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden