text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set FolderActionName to contents of EachFolder
|
lns3.scpt
|
set FAScripts to name of every script of folder action FolderActionName
|
lns3.scpt
|
set ChosenScripts to choose from list FAScripts ¬
|
lns3.scpt
|
with prompt ChooseScriptPrompt & EachFolder with multiple selections allowed
|
lns3.scpt
|
if class of ChosenScripts is boolean then
|
lns3.scpt
|
repeat with EachScript in ChosenScripts
|
lns3.scpt
|
set ScriptName to contents of EachScript
|
lns3.scpt
|
delete script ScriptName of folder action FolderActionName
|
lns3.scpt
|
if (count of FAScripts) is (count of ChosenScripts) then ¬
|
lns3.scpt
|
delete folder action FolderActionName
|
lns3.scpt
|
display dialog NoFoldersActionsExist with icon note
|
lns3.scpt
|
tell application "System Events" to set folder actions enabled to true
|
lns3.scpt
|
tell application "System Events" to set folder actions enabled to false
|
lns3.scpt
|
property ChooseScriptPrompt : "Select compiled script file(s) containing folder actions"
|
lns3.scpt
|
property ChooseFolderPrompt : "Select a folder to attach actions"
|
lns3.scpt
|
property ErrorMsg : " is not a compiled script. (Ignored)."
|
lns3.scpt
|
on open DroppedItems
|
lns3.scpt
|
choose folder with prompt ChooseFolderPrompt
|
lns3.scpt
|
set TargetFolder to the result as text
|
lns3.scpt
|
set FAName to name of alias TargetFolder
|
lns3.scpt
|
if folder action FAName exists then
|
lns3.scpt
|
make new folder action ¬
|
lns3.scpt
|
at end of folder actions ¬
|
lns3.scpt
|
with properties {path:TargetFolder} -- name:FAName,
|
lns3.scpt
|
repeat with EachItem in DroppedItems
|
lns3.scpt
|
set ItemInfo to info for EachItem
|
lns3.scpt
|
if not folder of ItemInfo then
|
lns3.scpt
|
set FileTypeOfItem to file type of ItemInfo
|
lns3.scpt
|
set FileExtensionOfItem to name extension of ItemInfo
|
lns3.scpt
|
set ItemName to name of ItemInfo
|
lns3.scpt
|
if FileTypeOfItem is "osas" or FileExtensionOfItem is "scpt" then
|
lns3.scpt
|
tell folder action FAName
|
lns3.scpt
|
make new script ¬
|
lns3.scpt
|
at end of scripts ¬
|
lns3.scpt
|
with properties {name:ItemName}
|
lns3.scpt
|
display dialog ItemName & ErrorMsg with icon caution
|
lns3.scpt
|
my ChooseFileFromFAScriptFolder()
|
lns3.scpt
|
open the result
|
lns3.scpt
|
to ChooseFileFromFAScriptFolder()
|
lns3.scpt
|
set LibraryScripts to list folder (path to Folder Action scripts folder from local domain) without invisibles
|
lns3.scpt
|
set LibraryScripts to {}
|
lns3.scpt
|
set UserScripts to list folder (path to Folder Action scripts folder from user domain) without invisibles
|
lns3.scpt
|
set UserScripts to {}
|
lns3.scpt
|
if (count LibraryScripts) + (count UserScripts) is greater than 0 then
|
lns3.scpt
|
set ChosenScripts to choose from list LibraryScripts & UserScripts with prompt ChooseScriptPrompt ¬
|
lns3.scpt
|
with multiple selections allowed
|
lns3.scpt
|
set SelectedScripts to {}
|
lns3.scpt
|
if EachScript is in LibraryScripts then
|
lns3.scpt
|
copy alias ((path to Folder Action scripts folder from local domain as Unicode text) & EachScript) to end of SelectedScripts
|
lns3.scpt
|
else if EachScript is in UserScripts then
|
lns3.scpt
|
copy alias ((path to Folder Action scripts folder from user domain as Unicode text) & EachScript) to end of SelectedScripts
|
lns3.scpt
|
return SelectedScripts
|
lns3.scpt
|
end ChooseFileFromFAScriptFolder
|
lns3.scpt
|
tell application "Font Book"
|
lns3.scpt
|
set styleNames to «class fbsn» of every «class fbfc»
|
lns3.scpt
|
set uniqueStyles to {}
|
lns3.scpt
|
repeat with aStyle in styleNames
|
lns3.scpt
|
if aStyle is not in uniqueStyles then
|
lns3.scpt
|
set uniqueStyles to uniqueStyles & aStyle
|
lns3.scpt
|
set chooseResult to choose from list my sortList(uniqueStyles) with prompt "Please select a style name."
|
lns3.scpt
|
if chooseResult is false then
|
lns3.scpt
|
set styleName to item 1 of chooseResult
|
lns3.scpt
|
set collectionName to "Style - " & styleName
|
lns3.scpt
|
if not («class fbcl» collectionName exists) then
|
lns3.scpt
|
make new «class fbcl» with properties {name:collectionName}
|
lns3.scpt
|
«event fbokfbad» (every «class fbfc» whose «class fbsn» is styleName) given «class fbto»:«class fbcl» collectionName
|
lns3.scpt
|
on sortList(listToSort)
|
lns3.scpt
|
set n to count of listToSort
|
lns3.scpt
|
if n is less than 2 then
|
lns3.scpt
|
return listToSort
|
lns3.scpt
|
else if n is 2 then
|
lns3.scpt
|
if item 1 of listToSort comes before item 2 of listToSort then
|
lns3.scpt
|
return reverse of listToSort
|
lns3.scpt
|
set p to the first item of listToSort
|
lns3.scpt
|
set listToSort to the rest of listToSort
|
lns3.scpt
|
set lowHalf to {}
|
lns3.scpt
|
set highHalf to {}
|
lns3.scpt
|
repeat with i in listToSort
|
lns3.scpt
|
if i comes before p then
|
lns3.scpt
|
set lowHalf to lowHalf & i
|
lns3.scpt
|
set highHalf to highHalf & i
|
lns3.scpt
|
return sortList(lowHalf) & p & sortList(highHalf)
|
lns3.scpt
|
end sortList
|
lns3.scpt
|
set fontNames to name of every «class fbfc»
|
lns3.scpt
|
set fontTypes to «class fbft» of every «class fbfc»
|
lns3.scpt
|
set uniqueTypes to {}
|
lns3.scpt
|
repeat with i from 1 to count fontNames
|
lns3.scpt
|
set thisName to item i of fontNames
|
lns3.scpt
|
set thisType to item i of fontTypes
|
lns3.scpt
|
if thisName does not start with "." then
|
lns3.scpt
|
if thisType is not in uniqueTypes then
|
lns3.scpt
|
set the end of uniqueTypes to thisType
|
lns3.scpt
|
set chooseResult to choose from list my sortList(uniqueTypes) with prompt "Please select a font type."
|
lns3.scpt
|
set fontTypeName to item 1 of chooseResult
|
lns3.scpt
|
set collectionName to "Font type - " & fontTypeName
|
lns3.scpt
|
«event fbokfbad» (every «class fbfc» whose «class fbft» is fontTypeName) given «class fbto»:«class fbcl» collectionName
|
lns3.scpt
|
set «class fbcc» to «class fbcl» collectionName
|
lns3.scpt
|
set result to display dialog "Enter text to look for in font's copyright information:" default answer "Apple"
|
lns3.scpt
|
if button returned of result is "好" then
|
lns3.scpt
|
set searchText to text returned of result
|
lns3.scpt
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.