Heikos Little Helpers: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
Line 85: Line 85:
=== Sources ===
=== Sources ===
You might be interested in how that stuff works. Take a look:
You might be interested in how that stuff works. Take a look:
HeiMac:Little Helpers Scripts heiko$ ./getSourceOfAppleScripts.sh
----------------------------------------------------------------------
Dumping ./Archive Selected File or Folder.scpt
2010-04-23 23:10:41.452 osadecompile[34906:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* Script to archive selected files/folders and name them <br>
<br>
History: <br>
<br>
2009-11-12, 12.10, hk: First version is working. <br>
<br>
ToDo:<br>
<br>
-strip leading directories from archive, so that they don't get created when expanding...<br>
<br>
<br>
<br>
*)<br>
on run (argv)<br>
tell application "Finder"<br>
set selectedItems to selection<br>
if ((count of selectedItems) is 1) then<br>
# else if ((count of selectedItems) is greater than 1) then<br>
set theItem to first item in selectedItems #as alias<br>
#get class of theItem<br>
set theItemClass to class of theItem<br>
log theItemClass<br>
set theItemName to name of theItem<br>
set theItemContainer to (container of theItem) as alias<br>
set itemPath to POSIX path of (theItem as alias)<br>
set itemContainerPath to POSIX path of theItemContainer<br>
if (theItemClass is folder) then (* not using type because it's localized, class is not *)<br>
(* remove trailing "/" *)<br>
set l to length of itemPath<br>
set itemPath to text 1 thru (l - 1) of itemPath<br>
log "shortened: " & itemPath<br>
else<br>
# mach nix <br>
end if<br>
set zipFileName to theItemName & " " & my timestamp() & ".zip"<br>
#set zipFilePath to itemContainerPath & "" & theItemName & "_" & my timestamp() & ".zip"<br>
#trasht alle dirs im zip set cmd to "zip -j -r \"" & zipFilePath & "\" \"" & itemPath & "\"" # -m<br>
set cmd to "cd \"" & itemContainerPath & "\" && zip -r \"" & zipFileName & "\" \"" & theItemName & "\"" # -m<br>
# set cmd to "zip \"" & zipFilePath & "\" -x .\\* \"" & itemPath & "\""<br>
log cmd<br>
do shell script cmd<br>
else<br>
display dialog "Please select one files/folders in Finder." buttons "Allright, I do whatever you say!"<br>
end if<br>
end tell<br>
end run<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
(* get a time stamp *)<br>
on timestamp()<br>
set dateNow to current date<br>
set dateYear to year of dateNow<br>
set dateMonth to addLeadingZeros(2, (month of dateNow as number) as string)<br>
set dateDay to addLeadingZeros(2, day of dateNow)<br>
set dateHour to addLeadingZeros(2, hours of dateNow)<br>
set dateMinute to addLeadingZeros(2, minutes of dateNow)<br>
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & " " & dateHour & "-" & dateMinute) as string<br>
end timestamp<br>
<br>
(* Liefert von einer Zahl n leading zeros zurück *)<br>
on addLeadingZeros(zeroesCount, value)<br>
<br>
(* nimmt die letzten zeroesCount Stellen des Strings *)<br>
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)<br>
log "newNumber: " & newNumber<br>
<br>
return (newNumber)<br>
end addLeadingZeros<br>
<br>
<br>
----------------------------------------------------------------------
Dumping ./Copy Selected Mail To Clipboard.scpt
2010-04-23 23:10:41.558 osadecompile[34909:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* copies selected mail from apple mail to clipboard as text *)<br>
<br>
tell application "Mail"<br>
<br>
set theSelectedMessages to selection<br>
<br>
if (count theSelectedMessages) is greater than 0 then<br>
<br>
repeat with oneSelectedMessage in theSelectedMessages<br>
tell oneSelectedMessage<br>
set t to all headers<br>
set t to t & return & content<br>
log t<br>
tell application "System Events"<br>
set the clipboard to t<br>
end tell<br>
end tell<br>
end repeat<br>
<br>
else<br>
display dialog "You haven't selected any message..." buttons {"Doh!"}<br>
end if<br>
<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./Dial Selected Number.scpt
2010-04-23 23:10:41.706 osadecompile[34912:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "System Events" to keystroke "c" using {command down}<br>
delay 0.1<br>
set someword to the clipboard<br>
<br>
tell application "direct.app" to «event ****DiMC» given «class DEST»:someword as string<br>
<br>
----------------------------------------------------------------------
Dumping ./Google Images Selected Text.scpt
2010-04-23 23:10:41.849 osadecompile[34915:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "System Events" to keystroke "c" using {command down}<br>
delay 0.1<br>
get the clipboard<br>
set someword to the clipboard<br>
<br>
tell application "Safari"<br>
activate<br>
open location "http://google.com/images?q='" & someword & "'"<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./Google Selected Text.scpt
2010-04-23 23:10:42.003 osadecompile[34918:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "System Events" to keystroke "c" using {command down}<br>
delay 0.1<br>
set someword to the clipboard<br>
<br>
tell application "Safari"<br>
activate<br>
open location "http://google.com/search?q='" & someword & "'"<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/*****.scpt
2010-04-23 23:10:42.155 osadecompile[34921:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
set r to 5<br>
set t to current track<br>
set rating of t to 100 / 5 * r<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/****.scpt
2010-04-23 23:10:42.313 osadecompile[34925:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
set r to 4<br>
set t to current track<br>
set rating of t to 100 / 5 * r<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/***.scpt
2010-04-23 23:10:42.419 osadecompile[34928:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
set r to 3<br>
set t to current track<br>
set rating of t to 100 / 5 * r<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/**.scpt
2010-04-23 23:10:42.529 osadecompile[34931:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
set r to 2<br>
set t to current track<br>
set rating of t to 100 / 5 * r<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/*.scpt
2010-04-23 23:10:42.632 osadecompile[34934:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
set r to 1<br>
set t to current track<br>
set rating of t to 100 / 5 * r<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Google Album Artwork Of Current Track.scpt
2010-04-23 23:10:42.754 osadecompile[34937:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
# set tName to name of current track<br>
set tArtist to artist of current track<br>
set tAlbum to album of current track<br>
# set queryText to tArtist & " " & tAlbum<br>
set queryText to "\"" & tArtist & "\" \"" & tAlbum & "\""<br>
end tell<br>
<br>
tell application "Safari"<br>
activate<br>
open location "http://google.com/images?q=" & queryText<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Google Lyrics Of Current Track.scpt
2010-04-23 23:10:42.877 osadecompile[34940:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
<br>
set tArtist to artist of current track<br>
set tName to name of current track<br>
--set queryText to "lyrics " & tArtist & " " & tName<br>
set queryText to "lyrics \"" & tArtist & "\" \"" & tName & "\""<br>
set queryText to my replace_chars(queryText, "&", "%26") # see http://www.degraeve.com/reference/urlencoding.php<br>
end tell<br>
<br>
tell application "Safari"<br>
activate<br>
open location "http://google.com/search?q=" & queryText<br>
end tell<br>
<br>
# see http://forums.macosxhints.com/archive/index.php/t-26666.html<br>
on replace_chars(this_text, search_string, replacement_string)<br>
set AppleScript's text item delimiters to the search_string<br>
set the item_list to every text item of this_text<br>
set AppleScript's text item delimiters to the replacement_string<br>
set this_text to the item_list as string<br>
set AppleScript's text item delimiters to ""<br>
return this_text<br>
end replace_chars<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Open Current Track's Lyrics in TextEdit.scpt
2010-04-23 23:10:43.008 osadecompile[34943:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* Just for reading - it's more comfy than in iTune's info-window *)<br>
tell application "iTunes"<br>
<br>
set l to lyrics of current track<br>
<br>
tell application "TextEdit"<br>
activate<br>
<br>
set newDoc to make new document<br>
set text of newDoc to l<br>
<br>
end tell<br>
<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Paste Current iTunes Track with Album.scpt
2010-04-23 23:10:43.131 osadecompile[34946:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
get player state<br>
if player state is not paused and player state is not stopped then<br>
tell current track<br>
set message to artist & " - " & album & " - " & name<br>
end tell<br>
# set artist to  artist of current track<br>
# set album to  album of current track<br>
# set title to name of current track<br>
set the clipboard to message<br>
tell application "System Events" to keystroke "v" using {command down}<br>
end if<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Paste Current iTunes Track.scpt
2010-04-23 23:10:43.293 osadecompile[34949:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
get player state<br>
if player state is not paused and player state is not stopped then<br>
tell current track<br>
set message to artist & " - " & name<br>
end tell<br>
set the clipboard to message<br>
tell application "System Events" to keystroke "v" using {command down}<br>
end if<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Show Current Track's Whole Album in Library.scpt
2010-04-23 23:10:43.461 osadecompile[34952:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
# http://dougscripts.com/itunes/itinfo/info02.php<br>
# http://dougscripts.com/itunes/itinfo/itunes72info.php<br>
tell application "iTunes"<br>
#activate<br>
<br>
display dialog "Not Working yet!"<br>
return<br>
<br>
<br>
<br>
set ct to current track<br>
set tName to name of ct<br>
set tArtist to artist of ct<br>
set tAlbum to album of ct<br>
set queryText to tArtist & " " & tAlbum<br>
#KO set albumTracks to search l for tAlbum only albums<br>
#OK set albumTracks to search playlist "Library" for tAlbum only albums<br>
set albumTracks to (every file track of playlist "Library" whose album contains tAlbum and artist contains tArtist)<br>
log albumTracks<br>
<br>
# Maybe I can select the Library and the tracks with some dirty tricks<br>
tell application "System Events"<br>
tell process "iTunes"<br>
get window 1<br>
#get every item of window 1<br>
#get outlines of window 1<br>
#get buttons of window 1<br>
#get browsers of window 1<br>
#get drawers of window 1<br>
#get lists of window 1<br>
#get text fields of window 1<br>
# Plenty of UI Elements:<br>
get UI elements of window 1<br>
# Splitter Group?<br>
set sg to splitter group of window 1<br>
get UI elements of sg<br>
set u to UI elements of sg<br>
log u # empty<br>
# Grow Area?<br>
set g to grow area 1 of window 1<br>
get UI elements of g<br>
set u to UI elements of g<br>
log u #empty<br>
# scroll area 1 (the yellow thingy)<br>
set s to scroll area 1 of window 1<br>
get UI elements of s<br>
set u to UI elements of s<br>
log u<br>
<br>
end tell<br>
end tell<br>
<br>
<br>
<br>
# Ab hier Bastelbude: #######################<br>
<br>
#set t to first item in albumTracks<br>
#log location of t<br>
#set view of (browser window 1) to parent of t<br>
<br>
(* geht nicht:<br>
reveal file track id 120028 of library playlist id 84927 of source id 48 *)<br>
# set t to first item in albumTracks<br>
# reveal t<br>
<br>
(* geht: <br>
reveal file track id 489116 of user playlist id 488505 of source id 48<br>
<br>
*)<br>
# set t to current track<br>
# reveal t<br>
<br>
<br>
<br>
#KO reveal first item in albumTracks<br>
<br>
#KO reveal playlist "Library"<br>
<br>
#? reveal current track<br>
#KO reveal (first item in albumTracks) of playlist "Library"<br>
<br>
#KO reveal first item in albumTracks<br>
<br>
<br>
(*OK set t to current track<br>
reveal t *)<br>
#OK reveal current track<br>
<br>
# log name of view of (browser window 1)<br>
#log name of view of (front browser window)<br>
<br>
# <br>
#set view of (browser window 1) to library playlist<br>
#set view of (browser window 1) to library playlist 1<br>
<br>
#set view of front browser window to library playlist 1<br>
<br>
<br>
# set l to library playlist<br>
# log l<br>
<br>
<br>
<br>
# log name of l<br>
#log parent of l<br>
# log source of l<br>
<br>
<br>
#log browser window<br>
# set view of front browser window to playlist "Library"<br>
#set view of front browser window to library playlist<br>
<br>
# set view of front browser window to user playlist "Library" of source "Library"<br>
<br>
#set selection to albumTracks<br>
#browser window<br>
end tell<br>
<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Speak Current Track.scpt
2010-04-23 23:10:43.623 osadecompile[34955:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
get player state<br>
if player state is not paused and player state is not stopped then<br>
tell current track<br>
set message to "Now playing " & name & " of the album " & album & " from " & artist<br>
end tell<br>
tell AppleScript to say message using "Victoria" (* see http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as304.html *)<br>
end if<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Volume/Decrease (-) Volume.scpt
2010-04-23 23:10:43.769 osadecompile[34958:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
set whatToDo to "dec" (* can be "inc", "dec", "mute" *)<br>
<br>
<br>
(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)<br>
set currentVolume to output volume of (get volume settings)<br>
set scaledVolume to round (currentVolume / (100 / 16))<br>
<br>
if (whatToDo contains "mute") then<br>
set volume with output muted<br>
else<br>
if (whatToDo contains "inc") then<br>
(* Use this code to increase the volume by a certain interval *)<br>
set soundInterval to 1<br>
set scaledVolume to scaledVolume + soundInterval<br>
if (scaledVolume > 16) then<br>
set scaledVolume to 16<br>
end if<br>
else if (whatToDo contains "dec") then<br>
(* OR use this code to decrease the output volume by 1 *)<br>
set scaledVolume to scaledVolume - 1<br>
if (scaledVolume < 0) then<br>
set scaledVolume to 0<br>
end if<br>
else<br>
set scaledVolume to scaledVolume<br>
end if<br>
<br>
(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)<br>
set newVolume to round (scaledVolume / 16 * 100)<br>
set volume output volume newVolume<br>
<br>
end if<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Volume/Increase (+) Volume.scpt
2010-04-23 23:10:43.887 osadecompile[34961:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
set whatToDo to "inc" (* can be "inc", "dec", "mute" *)<br>
<br>
<br>
(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)<br>
set currentVolume to output volume of (get volume settings)<br>
set scaledVolume to round (currentVolume / (100 / 16))<br>
<br>
if (whatToDo contains "mute") then<br>
set volume with output muted<br>
else<br>
if (whatToDo contains "inc") then<br>
(* Use this code to increase the volume by a certain interval *)<br>
set soundInterval to 1<br>
set scaledVolume to scaledVolume + soundInterval<br>
if (scaledVolume > 16) then<br>
set scaledVolume to 16<br>
end if<br>
else if (whatToDo contains "dec") then<br>
(* OR use this code to decrease the output volume by 1 *)<br>
set scaledVolume to scaledVolume - 1<br>
if (scaledVolume < 0) then<br>
set scaledVolume to 0<br>
end if<br>
else<br>
set scaledVolume to scaledVolume<br>
end if<br>
<br>
(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)<br>
set newVolume to round (scaledVolume / 16 * 100)<br>
set volume output volume newVolume<br>
<br>
end if<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Volume/Mute Volume.scpt
2010-04-23 23:10:43.992 osadecompile[34964:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
set whatToDo to "dec" (* can be "inc", "dec", "mute" *)<br>
<br>
<br>
(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)<br>
set currentVolume to output volume of (get volume settings)<br>
set scaledVolume to round (currentVolume / (100 / 16))<br>
<br>
if (whatToDo contains "mute") then<br>
set volume with output muted<br>
else<br>
if (whatToDo contains "inc") then<br>
(* Use this code to increase the volume by a certain interval *)<br>
set soundInterval to 1<br>
set scaledVolume to scaledVolume + soundInterval<br>
if (scaledVolume > 16) then<br>
set scaledVolume to 16<br>
end if<br>
else if (whatToDo contains "dec") then<br>
(* OR use this code to decrease the output volume by 1 *)<br>
set scaledVolume to scaledVolume - 1<br>
if (scaledVolume < 0) then<br>
set scaledVolume to 0<br>
end if<br>
else<br>
set scaledVolume to scaledVolume<br>
end if<br>
<br>
(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)<br>
set newVolume to round (scaledVolume / 16 * 100)<br>
set volume output volume newVolume<br>
<br>
end if<br>
----------------------------------------------------------------------
Dumping ./iTunes Currently Playing Track/Volume/Toggle Mute.scpt
2010-04-23 23:10:44.100 osadecompile[34967:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* Mute/Unute<br>
*)<br>
set _muted to (get (output muted of (get volume settings)))<br>
if _muted is false then<br>
set volume with output muted<br>
else<br>
set volume without output muted<br>
end if<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/*****.scpt
2010-04-23 23:10:44.188 osadecompile[34970:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
repeat with aTrack in sel<br>
<br>
set r to 5<br>
set rating of aTrack to 100 / 5 * r<br>
<br>
end repeat<br>
end if<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/****.scpt
2010-04-23 23:10:44.308 osadecompile[34973:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
repeat with aTrack in sel<br>
<br>
set r to 4<br>
set rating of aTrack to 100 / 5 * r<br>
<br>
end repeat<br>
end if<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/***.scpt
2010-04-23 23:10:44.427 osadecompile[34976:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
repeat with aTrack in sel<br>
<br>
set r to 3<br>
set rating of aTrack to 100 / 5 * r<br>
<br>
end repeat<br>
end if<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/**.scpt
2010-04-23 23:10:44.540 osadecompile[34979:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
repeat with aTrack in sel<br>
<br>
set r to 2<br>
set rating of aTrack to 100 / 5 * r<br>
<br>
end repeat<br>
end if<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/*.scpt
2010-04-23 23:10:44.644 osadecompile[34982:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
repeat with aTrack in sel<br>
<br>
set r to 1<br>
set rating of aTrack to 100 / 5 * r<br>
<br>
end repeat<br>
end if<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Google Album Artwork Of Selected Track.scpt
2010-04-23 23:10:44.752 osadecompile[34985:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
set sel to a reference to selection<br>
if ((count of sel) > 1) then<br>
activate<br>
set res to display dialog "Are you sure you want Artwork for more than one track?" buttons {"I know what I'm doing", "Ah, no, thank you!"}<br>
#if <br>
log res<br>
if button returned of res is not "I know what I'm doing" then<br>
return<br>
end if<br>
end if<br>
repeat with aTrack in sel<br>
set tArtist to artist of aTrack<br>
set tAlbum to album of aTrack<br>
set queryText to "\"" & tArtist & "\" \"" & tAlbum & "\""<br>
tell application "Safari"<br>
activate<br>
open location "http://google.com/images?q=" & queryText & ""<br>
end tell<br>
end repeat<br>
end if<br>
end tell<br>
<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Google Lyrics Of Selected Track.scpt
2010-04-23 23:10:44.872 osadecompile[34988:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 1 or trackCount is less than 1 then<br>
activate<br>
set msg to "You selected " & trackCount & " tracks. Please select exactly one. Thanks a bunch."<br>
set res to display dialog msg buttons {"Sure!"}<br>
return<br>
end if<br>
<br>
set aTrack to first item in sel<br>
<br>
set tArtist to artist of aTrack<br>
set tName to name of aTrack<br>
set queryText to "lyrics \"" & tArtist & "\" \"" & tName & "\""<br>
set queryText to my replace_chars(queryText, "&", "%26") # see http://www.degraeve.com/reference/urlencoding.php<br>
<br>
tell application "Safari"<br>
activate<br>
# open location "http://google.com/search?q='" & queryText & "'"<br>
open location "http://google.com/search?q=" & queryText & ""<br>
end tell<br>
<br>
end if<br>
<br>
end tell<br>
<br>
<br>
# see http://forums.macosxhints.com/archive/index.php/t-26666.html<br>
on replace_chars(this_text, search_string, replacement_string)<br>
set AppleScript's text item delimiters to the search_string<br>
set the item_list to every text item of this_text<br>
set AppleScript's text item delimiters to the replacement_string<br>
set this_text to the item_list as string<br>
set AppleScript's text item delimiters to ""<br>
return this_text<br>
end replace_chars<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Paste Selected iTunes Tracks with Album.scpt
2010-04-23 23:10:45.027 osadecompile[34991:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to do this with the selected " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
set message to ""<br>
repeat with aTrack in sel<br>
<br>
tell aTrack<br>
set message to message & artist & " - " & album & " - " & name & return<br>
end tell<br>
<br>
end repeat<br>
<br>
set the clipboard to message<br>
<br>
tell application "System Events" to keystroke "v" using {command down}<br>
<br>
end if<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Paste Selected iTunes Tracks.scpt
2010-04-23 23:10:45.171 osadecompile[34994:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
<br>
if selection is not {} then -- there ARE tracks selected...<br>
<br>
set sel to a reference to selection<br>
set trackCount to count sel<br>
if trackCount is greater than 23 then<br>
set msg to "Are you sure, you want to do this with the selected " & trackCount & " tracks?"<br>
set res to display dialog msg buttons {"Sure!", "Actually, no."}<br>
if button returned of res is not "Sure!" then<br>
return<br>
end if<br>
end if<br>
<br>
set message to ""<br>
repeat with aTrack in sel<br>
<br>
tell aTrack<br>
set message to message & artist & " - " & name & return<br>
end tell<br>
<br>
end repeat<br>
<br>
set the clipboard to message<br>
<br>
tell application "System Events" to keystroke "v" using {command down}<br>
<br>
end if<br>
end tell<br>
<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Play Single Track.scpt
2010-04-23 23:10:45.325 osadecompile[34997:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* <br>
Ever wondered how you can play a single track? Think of it: You navigate to a track in your music library, and you want to play it. Just this one.<br>
Yes: iTunes offers no method of doing this (except creating a new playlist, adding the track, playing the track und deleting the playlist afterwards. Yes, this sucks).<br>
<br>
The bad news: I have no better solution.<br>
Now the good news: You don't have to do it yourself! Here's the script that does it all for you: (place into ~/Library/iTunes/Scripts/ or ~/Library/Scripts/)<br>
*)<br>
<br>
global tempplaylistname<br>
on run<br>
(* Init *)<br>
<br>
set tempplaylistname to "temp"<br>
<br>
(* Create new playlist, if not existing *)<br>
tell me to set pl to newtempplaylist()<br>
<br>
(* selected track -> pl *)<br>
tell application "iTunes"<br>
<br>
(* remember old playlist *)<br>
set oldpl to view of (browser window 1)<br>
<br>
(* Now the magic... *)<br>
try<br>
get class of selection<br>
# log selection<br>
# if ((count of selection) is greater than 0) then<br>
set t to first item in selection<br>
<br>
(* track into playlist *)<br>
duplicate t to pl<br>
<br>
(* playlist repeat off *)<br>
set song repeat of pl to off<br>
<br>
(* playlist to front *)<br>
try<br>
#set view of front window to playlist pl<br>
#set view of browser window to pl<br>
#set view of (browser window 1) to user playlist pl (*Fuck! (iTunes got an error: A descriptor type mismatch occurred.)*)<br>
set view of (browser window 1) to pl (* Works with iTunes 9 *)<br>
on error (e)<br>
log "Fuck! (" & e & ")"<br>
end try<br>
<br>
(* play track *)<br>
play first item of tracks of pl<br>
<br>
(* Wait until track played or stopped *)<br>
set dur to duration of t<br>
repeat dur times<br>
if player state is not playing then exit repeat<br>
delay 1.0<br>
end repeat<br>
<br>
(* restore old playlist *)<br>
set view of (browser window 1) to oldpl<br>
on error (e)<br>
display dialog "Select something, you weenie!" buttons "Yes, your highness!"<br>
end try<br>
<br>
(* delete temp playlist *)<br>
delete pl<br>
end tell<br>
end run<br>
<br>
(* Create a temp playlist we will delete afterwards *)<br>
on newtempplaylist()<br>
tell application "iTunes"<br>
set pl to make new user playlist with properties {name:tempplaylistname & " as of " & (current date) as string}<br>
end tell<br>
return pl<br>
end newtempplaylist<br>
----------------------------------------------------------------------
Dumping ./iTunes Selected Tracks/Remove Leading  "01" from Title.scpt
2010-04-23 23:10:45.439 osadecompile[35000:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
tell application "iTunes"<br>
<br>
tell application "iTunes"<br>
if selection is not {} then -- there ARE tracks selected...<br>
set sel to a reference to selection<br>
repeat with aTrack in sel<br>
<br>
set oldName to name of aTrack<br>
log "Processing :" & oldName<br>
<br>
set cmd to "echo \"" & oldName & "\" | sed s/01\\ //\\g"<br>
tell application "Finder"<br>
set newName to do shell script cmd<br>
end tell<br>
log "Setting new name: " & newName<br>
<br>
set name of aTrack to newName<br>
<br>
end repeat<br>
end if<br>
end tell<br>
<br>
end tell<br>
----------------------------------------------------------------------
Dumping ./Leo Selected Text.scpt
2010-04-23 23:10:45.566 osadecompile[35003:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* Copy selected string to clipboard *)<br>
tell application "System Events"<br>
(* Try using Cmd-C *)<br>
set oldClipboard to the clipboard<br>
keystroke "c" using {command down}<br>
set someword to the clipboard<br>
if (oldClipboard is equal to someword) then<br>
log "Most likely you held some more modifiers down (f.e. if you launch this script with FastScripts and a Shortcut that uses option, control or shift..)"<br>
(* Trying to invoke "Copy" Menu command *)<br>
set appName to name of current application<br>
# my menu_click({appName, my menuEditLocalized(), my menuItemEditCopyLocalized(), ""})<br>
tell application "System Events"<br>
set procs to every process<br>
repeat with p in procs<br>
if frontmost of p is true then<br>
set proc to p<br>
end if<br>
end repeat<br>
#set proc to items of processes whose frontmost is true<br>
#set proc to item 1 of processes<br>
get proc<br>
#click menu item "Copy" of ((proc)'s (menu bar 1)'s (menu bar item "Edit"))<br>
set menuBar to menu bar 1 of proc<br>
set editMenu to menu bar item whose name is (my menuEditLocalized())<br>
return 0<br>
end tell<br>
end if<br>
#delay 0.5<br>
end tell<br>
<br>
<br>
(* Open Browser with query *)<br>
tell application "Safari"<br>
activate<br>
open location "http://dict.leo.org/?search='" & someword & "'"<br>
end tell<br>
<br>
<br>
(* get localized copy menu item name *)<br>
on menuItemEditCopyLocalized()<br>
tell AppleScript<br>
set cmd to "defaults read NSGlobalDomain AppleLanguages | grep -v \"^(\" | grep -v \"^)\" | head -1 | cut -d, -f1 | awk '{printf $1}'"<br>
set languageCode to do shell script cmd<br>
if (languageCode is "de") then<br>
return "Kopieren"<br>
else if (languageCode is "en") then<br>
return "Copy"<br>
else<br>
log "WTF?"<br>
return ""<br>
end if<br>
end tell<br>
end menuItemEditCopyLocalized<br>
<br>
<br>
(* get localized copy menu name *)<br>
on menuEditLocalized()<br>
tell AppleScript<br>
set cmd to "defaults read NSGlobalDomain AppleLanguages | grep -v \"^(\" | grep -v \"^)\" | head -1 | cut -d, -f1 | awk '{printf $1}'"<br>
set languageCode to do shell script cmd<br>
if (languageCode is "de") then<br>
return "Bearbeiten"<br>
else if (languageCode is "en") then<br>
return "Edit"<br>
else<br>
log "WTF?"<br>
return ""<br>
end if<br>
end tell<br>
end menuEditLocalized<br>
<br>
<br>
<br>
<br>
(* This came from http://www.macosxhints.com/article.php?story=20060921045743404 *)<br>
on menu_click(mList)<br>
local appName, topMenu, r<br>
<br>
-- Validate our input<br>
if mList's length < 3 then error "Menu list is not long enough"<br>
<br>
-- Set these variables for clarity and brevity later on<br>
set {appName, topMenu} to (items 1 through 2 of mList)<br>
set r to (items 3 through (mList's length) of mList)<br>
<br>
-- This overly-long line calls the menu_recurse function with<br>
-- two arguments: r, and a reference to the top-level menu<br>
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬<br>
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))<br>
end menu_click<br>
<br>
on menu_click_recurse(mList, parentObject)<br>
local f, r<br>
<br>
-- `f` = first item, `r` = rest of items<br>
set f to item 1 of mList<br>
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)<br>
<br>
-- either actually click the menu item, or recurse again<br>
tell application "System Events"<br>
if mList's length is 1 then<br>
click parentObject's menu item f<br>
else<br>
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))<br>
end if<br>
end tell<br>
end menu_click_recurse<br>
----------------------------------------------------------------------
Dumping ./Look Up Selected Text In Dictionary.scpt
2010-04-23 23:10:45.721 osadecompile[35006:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* Unfortunately Dictionary is not scriptable but can only be automated with Automator. However there is always the dirty way using System Events. That's what I did to script Dictionary.<br>
*)<br>
<br>
(* Get selected text *)<br>
tell application "System Events" to keystroke "c" using {command down}<br>
<br>
(* Bring Dictionary to foreground *)<br>
tell application "Dictionary" to activate<br>
<br>
<br>
(* Paste selected text *)<br>
tell application "System Events" to keystroke "v" using {command down}<br>
<br>
<br>
(* Look up *)<br>
# tell application "System Events" to keystroke return<br>
<br>
<br>
<br>
----------------------------------------------------------------------
Dumping ./Paste Log Timestamp.scpt
2010-04-23 23:10:45.863 osadecompile[35009:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
on run (argv)<br>
# set oldClip to the clipboard<br>
<br>
set the clipboard to my timestamp()<br>
<br>
<br>
tell application "System Events" to keystroke "v" using {command down}<br>
<br>
# set the clipboard to oldClip<br>
end run<br>
<br>
<br>
(* get a time stamp *)<br>
on timestamp()<br>
set dateNow to current date<br>
set dateYear to year of dateNow<br>
set dateMonth to (month of dateNow as number)<br>
set dateDay to addLeadingZeros(2, day of dateNow)<br>
set dateHour to addLeadingZeros(2, hours of dateNow)<br>
set dateMinute to addLeadingZeros(2, minutes of dateNow)<br>
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & ", " & dateHour & ":" & dateMinute & ", hk: ") as string<br>
end timestamp<br>
<br>
(* Liefert von einer Zahl n leading zeros zurück *)<br>
on addLeadingZeros(zeroesCount, value)<br>
<br>
(* nimmt die letzten zeroesCount Stellen des Strings *)<br>
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)<br>
log "newNumber: " & newNumber<br>
<br>
return (newNumber)<br>
end addLeadingZeros<br>
<br>
<br>
----------------------------------------------------------------------
Dumping ./Paste Timestamp.scpt
2010-04-23 23:10:46.009 osadecompile[35012:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
set the clipboard to my timestamp()<br>
<br>
<br>
tell application "System Events" to keystroke "v" using {command down}<br>
<br>
<br>
<br>
(* get a time stamp *)<br>
on timestamp()<br>
set dateNow to current date<br>
set dateYear to year of dateNow<br>
set dateMonth to (month of dateNow as number)<br>
set dateDay to addLeadingZeros(2, day of dateNow)<br>
set dateHour to addLeadingZeros(2, hours of dateNow)<br>
set dateMinute to addLeadingZeros(2, minutes of dateNow)<br>
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & " " & dateHour & ":" & dateMinute) as string<br>
end timestamp<br>
<br>
(* Liefert von einer Zahl n leading zeros zurück *)<br>
on addLeadingZeros(zeroesCount, value)<br>
<br>
(* nimmt die letzten zeroesCount Stellen des Strings *)<br>
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)<br>
log "newNumber: " & newNumber<br>
<br>
return (newNumber)<br>
end addLeadingZeros<br>
<br>
----------------------------------------------------------------------
Dumping ./Reply Mail With Quote.scpt
2010-04-23 23:10:46.166 osadecompile[35015:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
(* History:<br>
2010-02-21, 16:44, hk: First version.<br>
                                      * If name contains "," reverse order!--DONE<br>
                                      * get original text--DONE<br>
  * check if already quoted, if not-> quote--DONE<br>
  * Leere Zeilen auch quoten--DONE<br>
  * Reply & set new content--DONE<br>
<br>
Bug: Erkennung des schon gequoteten buggt!--?<br>
<br>
ToDo:<br>
<br>
*)<br>
<br>
<br>
tell application "Mail"<br>
# tell message viewer<br>
# get selected messages <br>
# end tell<br>
set selectedMessages to selection<br>
set selectedMessagesCount to (count selectedMessages)<br>
if selectedMessagesCount > 0 then<br>
if selectedMessagesCount > 23 then<br>
set res to display dialog "Are you sure you want to reply on " & selectedMessagesCount & " messages?" buttons {"No", "Maybe", "Yes"}<br>
if button returned of res is not "Yes" then<br>
return<br>
end if<br>
end if<br>
(* Now, do the magic! *)<br>
repeat with selectedMessage in selectedMessages<br>
tell selectedMessage<br>
set smSender to sender<br>
(* cut the email-address *)<br>
tell me to set smSenderName to cutString of smSender by "<"<br>
(* If name contains "," cut the part before the "," and add it at the end (this way "Doe, John" will get "JD" instead of "DJ") *)<br>
if smSenderName contains "," then<br>
log "foo"<br>
tell me to set smSenderNameSurname to cutString of smSenderName by ","<br>
log smSenderNameSurname<br>
tell me to set smSenderNameFirstname to cutStringRemainder of smSenderName by ","<br>
log smSenderNameFirstname<br>
set smSenderName to (smSenderNameFirstname & " " & smSenderNameSurname) as text (* yes, that's ugly *)<br>
log smSenderName<br>
end if<br>
(* get initials of the name *)<br>
tell me to set smInitials to initialsOfName(smSenderName)<br>
(* get text of mail and walk lines... http://www.mactech.com/articles/mactech/Vol.21/21.07/WorkingWithText/index.html *)<br>
set smText to content<br>
set smTextQuoted to ""<br>
#log smText<br>
#set smTextLineCount to count paragraphs of smText<br>
<br>
(* Zeilen (=Paragraphs) abklappern *)<br>
repeat with p in (paragraphs of smText)<br>
<br>
(* Get line length *)<br>
set lineLength to (length of p)<br>
if lineLength > 5 then<br>
set lineLength to 5<br>
end if<br>
<br>
if lineLength > 0 then<br>
set pBegin to characters 1 thru lineLength of p<br>
else<br>
set pBegin to ""<br>
end if<br>
<br>
if pBegin contains ">" then<br>
(* is quoted -> just concatenate strings *)<br>
#log "already quoted: " & pBegin<br>
set smTextQuoted to smTextQuoted & (p as string) & return<br>
else<br>
<br>
#if pBegin does not contain ">" then<br>
(* not quoted yet, quote! *)<br>
set smTextQuoted to smTextQuoted & smInitials & "> " & (p as string) & return<br>
#else<br>
# (* already quoted *)<br>
# set smTextQuoted to smTextQuoted & (p as string) & return<br>
#end if<br>
#else<br>
#set smTextQuoted to smTextQuoted & (p as string) & return<br>
end if<br>
<br>
end repeat (* repeat with paragraphs *)<br>
log "quoted text: " & return & smTextQuoted<br>
end tell # tell selectedMail<br>
<br>
(* Backup quoting behaviour *)<br>
tell application "Mail" to set quotingSetting to quote original message<br>
tell application "Mail" to set quote original message to false<br>
<br>
(* now reply *)<br>
set newMessage to reply selectedMessage with opening window and reply to all<br>
if newMessage is false then<br>
log "Gee, reply failed."<br>
else<br>
tell newMessage<br>
log newMessage<br>
#set content of newMessage to "foo" -- smTextQuoted<br>
# make new content with properties {text:"smTextQuoted"}<br>
log (content)<br>
log (subject)<br>
log (sender)<br>
log (to recipients)<br>
#make new to recipient with properties {address:"MY ADDRESS"}<br>
log (to recipients)<br>
#make new content with t<br>
#log "s: " & (contents as text)<br>
set content to "foo"<br>
set content to smTextQuoted<br>
#make new content with properties {text:"MY text"}<br>
end tell<br>
end if # reply worked<br>
<br>
(* Restore quoting behaviour *)<br>
tell application "Mail" to set quote original message to quotingSetting<br>
<br>
end repeat (* repeat with mails *)<br>
else<br>
log ("You might want to select a message first")<br>
end if<br>
end tell<br>
<br>
(* Now get the first characters of every word (Initials) *)<br>
on initialsOfName(sendername)<br>
set initials to ""<br>
repeat with oneWord in (words of sendername)<br>
set initials to initials & first character of oneWord<br>
end repeat<br>
return initials<br>
end initialsOfName<br>
<br>
(* cuts all the text following the first occurance of the searchstring 'd' *)<br>
to cutString of t by d<br>
set oldd to text item delimiters<br>
set text item delimiters to d<br>
set t to t's text items<br>
set t to first item in t<br>
set text item delimiters to oldd<br>
t<br>
end cutString<br>
<br>
(* returns what cutString has cut off! *)<br>
to cutStringRemainder of t by d<br>
set oldd to text item delimiters<br>
set text item delimiters to d<br>
set t to t's text items<br>
set wordCount to count t<br>
if (wordCount > 1) then<br>
set t to items 2 through wordCount in t<br>
end if<br>
set text item delimiters to oldd<br>
t<br>
end cutStringRemainder<br>
<br>
(* Diese Funktion ersetzt einen String innerhalb eines strings durch einen anderen String. Quelle: http://macscripter.net/viewtopic.php?id=13008 *)<br>
to changeSubString of t from s to r<br>
set d to text item delimiters<br>
set text item delimiters to s<br>
set t to t's text items<br>
set text item delimiters to r<br>
tell t to set t to beginning & ({""} & rest)<br>
set text item delimiters to d<br>
t<br>
end changeSubString<br>
<br>
HeiMac:Little Helpers Scripts heiko$

Revision as of 23:10, 23 April 2010

About

Heiko's Little Helpers are a bunch of AppleScripts I wrote to do frequently needed jobs for me...
Originally I programmed an application named Sake to do that, but it became more complex than I anticipated...that's why I decided to discontinue Sake and switch to FastScripts.

What?

There are some things I often to by hand - this really bothered me. Therefore I sought a way to do this more efficiently.

System Requirements

Setup

  • Install FastScripts
  • Download this scripts (link below), unpack and move them either into...
    • ~/Library/Scripts (usable for your own user only)
    • /Library/Scripts (usable for all users of your Mac)

Usage

  • Example: Archive Selected File/Folder.scpt
    • Select the files you want to archive, in this case "Miscellaneous Scripts", and select Archive this! in FastScripts menu...
      Heikoslittlehelpers20091222a1.png
    • ...and you get this:
      Heikoslittlehelpers20091222b1.png

What it can do for you!

Script Function
Paste Timestamp.scpt Pastes a timestamp like "2009-12-22 16:29" into the current text editor.
Paste Log Timestamp.scpt Pastes timestamp like this: "2009-12-22, 16:32, hk: ". This is my favourite. I don't remember what it was like before I used this!
Archive Selected File/Folder.scpt You'll gonna love this: Creates an archive from your selected file/folder and adds an timestamp to the filename. That's sooo handy for my source backups.
Leo Selected Text.scpt Looks up selected text in http://www.leo.org .
Look Up Selected Text In Dictionary.scpt Looks up selected text in MacOS X's Dictionary.
Google Selected Text.scpt Looks up selected text in Google
Google Selected Text For Images.scpt Looks up selected text in Google Image search
Dial Selected Number.scpt Dials selected number with iLink Direct
Decrease Volume.scpt Decreases system volume
Increase Volume.scpt Decreases system volume
Mute Volume.scpt Mutes system volume
Toggle Mute.scpt Toggles muting of system volume
iTunes Rating Scripts.scpt Rates selected or current tracks
Google Album Artwork Of Current Track.scpt Guess what.
Google Album Artwork Of Selected Track.scpt Guess what.
Google Lyrics Of Current Track.scpt Guess what.
Google Lyrics Of Selected Track.scpt Guess what.
Paste iTunes Current Track.scpt Pastes the current iTunes track like this: "The Beez - Die Warteschleife - Die Warteschleife (Radio Edit)".

Download

Media:HeikoLittleHelpers.zip

Sources

You might be interested in how that stuff works. Take a look:


HeiMac:Little Helpers Scripts heiko$ ./getSourceOfAppleScripts.sh


Dumping ./Archive Selected File or Folder.scpt 2010-04-23 23:10:41.452 osadecompile[34906:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* Script to archive selected files/folders and name them 

History:

2009-11-12, 12.10, hk: First version is working.

ToDo:

-strip leading directories from archive, so that they don't get created when expanding...



*)
on run (argv)
tell application "Finder"
set selectedItems to selection
if ((count of selectedItems) is 1) then
# else if ((count of selectedItems) is greater than 1) then
set theItem to first item in selectedItems #as alias
#get class of theItem
set theItemClass to class of theItem
log theItemClass
set theItemName to name of theItem
set theItemContainer to (container of theItem) as alias
set itemPath to POSIX path of (theItem as alias)
set itemContainerPath to POSIX path of theItemContainer
if (theItemClass is folder) then (* not using type because it's localized, class is not *)
(* remove trailing "/" *)
set l to length of itemPath
set itemPath to text 1 thru (l - 1) of itemPath
log "shortened: " & itemPath
else
# mach nix
end if
set zipFileName to theItemName & " " & my timestamp() & ".zip"
#set zipFilePath to itemContainerPath & "" & theItemName & "_" & my timestamp() & ".zip"
#trasht alle dirs im zip set cmd to "zip -j -r \"" & zipFilePath & "\" \"" & itemPath & "\"" # -m
set cmd to "cd \"" & itemContainerPath & "\" && zip -r \"" & zipFileName & "\" \"" & theItemName & "\"" # -m
# set cmd to "zip \"" & zipFilePath & "\" -x .\\* \"" & itemPath & "\""
log cmd
do shell script cmd
else
display dialog "Please select one files/folders in Finder." buttons "Allright, I do whatever you say!"
end if
end tell
end run









(* get a time stamp *)
on timestamp()
set dateNow to current date
set dateYear to year of dateNow
set dateMonth to addLeadingZeros(2, (month of dateNow as number) as string)
set dateDay to addLeadingZeros(2, day of dateNow)
set dateHour to addLeadingZeros(2, hours of dateNow)
set dateMinute to addLeadingZeros(2, minutes of dateNow)
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & " " & dateHour & "-" & dateMinute) as string
end timestamp

(* Liefert von einer Zahl n leading zeros zurück *)
on addLeadingZeros(zeroesCount, value)

(* nimmt die letzten zeroesCount Stellen des Strings *)
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)
log "newNumber: " & newNumber

return (newNumber)
end addLeadingZeros



Dumping ./Copy Selected Mail To Clipboard.scpt 2010-04-23 23:10:41.558 osadecompile[34909:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* copies selected mail from apple mail to clipboard as text *)

tell application "Mail"

set theSelectedMessages to selection

if (count theSelectedMessages) is greater than 0 then

repeat with oneSelectedMessage in theSelectedMessages
tell oneSelectedMessage
set t to all headers
set t to t & return & content
log t
tell application "System Events"
set the clipboard to t
end tell
end tell
end repeat

else
display dialog "You haven't selected any message..." buttons {"Doh!"}
end if

end tell

Dumping ./Dial Selected Number.scpt 2010-04-23 23:10:41.706 osadecompile[34912:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "System Events" to keystroke "c" using {command down}
delay 0.1
set someword to the clipboard

tell application "direct.app" to «event ****DiMC» given «class DEST»:someword as string


Dumping ./Google Images Selected Text.scpt 2010-04-23 23:10:41.849 osadecompile[34915:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "System Events" to keystroke "c" using {command down}
delay 0.1
get the clipboard
set someword to the clipboard

tell application "Safari"
activate
open location "http://google.com/images?q='" & someword & "'"
end tell


Dumping ./Google Selected Text.scpt 2010-04-23 23:10:42.003 osadecompile[34918:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "System Events" to keystroke "c" using {command down}
delay 0.1
set someword to the clipboard

tell application "Safari"
activate
open location "http://google.com/search?q='" & someword & "'"
end tell

Dumping ./iTunes Currently Playing Track/*****.scpt 2010-04-23 23:10:42.155 osadecompile[34921:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
set r to 5
set t to current track
set rating of t to 100 / 5 * r
end tell

Dumping ./iTunes Currently Playing Track/****.scpt 2010-04-23 23:10:42.313 osadecompile[34925:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
set r to 4
set t to current track
set rating of t to 100 / 5 * r
end tell

Dumping ./iTunes Currently Playing Track/***.scpt 2010-04-23 23:10:42.419 osadecompile[34928:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
set r to 3
set t to current track
set rating of t to 100 / 5 * r
end tell

Dumping ./iTunes Currently Playing Track/**.scpt 2010-04-23 23:10:42.529 osadecompile[34931:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
set r to 2
set t to current track
set rating of t to 100 / 5 * r
end tell

Dumping ./iTunes Currently Playing Track/*.scpt 2010-04-23 23:10:42.632 osadecompile[34934:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
set r to 1
set t to current track
set rating of t to 100 / 5 * r
end tell

Dumping ./iTunes Currently Playing Track/Google Album Artwork Of Current Track.scpt 2010-04-23 23:10:42.754 osadecompile[34937:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
# set tName to name of current track
set tArtist to artist of current track
set tAlbum to album of current track
# set queryText to tArtist & " " & tAlbum
set queryText to "\"" & tArtist & "\" \"" & tAlbum & "\""
end tell

tell application "Safari"
activate
open location "http://google.com/images?q=" & queryText
end tell


Dumping ./iTunes Currently Playing Track/Google Lyrics Of Current Track.scpt 2010-04-23 23:10:42.877 osadecompile[34940:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"

set tArtist to artist of current track
set tName to name of current track
--set queryText to "lyrics " & tArtist & " " & tName
set queryText to "lyrics \"" & tArtist & "\" \"" & tName & "\""
set queryText to my replace_chars(queryText, "&", "%26") # see http://www.degraeve.com/reference/urlencoding.php
end tell

tell application "Safari"
activate
open location "http://google.com/search?q=" & queryText
end tell

# see http://forums.macosxhints.com/archive/index.php/t-26666.html
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars


Dumping ./iTunes Currently Playing Track/Open Current Track's Lyrics in TextEdit.scpt 2010-04-23 23:10:43.008 osadecompile[34943:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* Just for reading - it's more comfy than in iTune's info-window *)
tell application "iTunes"

set l to lyrics of current track

tell application "TextEdit"
activate

set newDoc to make new document
set text of newDoc to l

end tell

end tell

Dumping ./iTunes Currently Playing Track/Paste Current iTunes Track with Album.scpt 2010-04-23 23:10:43.131 osadecompile[34946:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
get player state
if player state is not paused and player state is not stopped then
tell current track
set message to artist & " - " & album & " - " & name
end tell
# set artist to artist of current track
# set album to album of current track
# set title to name of current track
set the clipboard to message
tell application "System Events" to keystroke "v" using {command down}
end if
end tell


Dumping ./iTunes Currently Playing Track/Paste Current iTunes Track.scpt 2010-04-23 23:10:43.293 osadecompile[34949:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
get player state
if player state is not paused and player state is not stopped then
tell current track
set message to artist & " - " & name
end tell
set the clipboard to message
tell application "System Events" to keystroke "v" using {command down}
end if
end tell


Dumping ./iTunes Currently Playing Track/Show Current Track's Whole Album in Library.scpt 2010-04-23 23:10:43.461 osadecompile[34952:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

# http://dougscripts.com/itunes/itinfo/info02.php
# http://dougscripts.com/itunes/itinfo/itunes72info.php
tell application "iTunes"
#activate

display dialog "Not Working yet!"
return



set ct to current track
set tName to name of ct
set tArtist to artist of ct
set tAlbum to album of ct
set queryText to tArtist & " " & tAlbum
#KO set albumTracks to search l for tAlbum only albums
#OK set albumTracks to search playlist "Library" for tAlbum only albums
set albumTracks to (every file track of playlist "Library" whose album contains tAlbum and artist contains tArtist)
log albumTracks

# Maybe I can select the Library and the tracks with some dirty tricks
tell application "System Events"
tell process "iTunes"
get window 1
#get every item of window 1
#get outlines of window 1
#get buttons of window 1
#get browsers of window 1
#get drawers of window 1
#get lists of window 1
#get text fields of window 1
# Plenty of UI Elements:
get UI elements of window 1
# Splitter Group?
set sg to splitter group of window 1
get UI elements of sg
set u to UI elements of sg
log u # empty
# Grow Area?
set g to grow area 1 of window 1
get UI elements of g
set u to UI elements of g
log u #empty
# scroll area 1 (the yellow thingy)
set s to scroll area 1 of window 1
get UI elements of s
set u to UI elements of s
log u

end tell
end tell



# Ab hier Bastelbude: #######################

#set t to first item in albumTracks
#log location of t
#set view of (browser window 1) to parent of t

(* geht nicht:
reveal file track id 120028 of library playlist id 84927 of source id 48 *)
# set t to first item in albumTracks
# reveal t

(* geht:
reveal file track id 489116 of user playlist id 488505 of source id 48

*)
# set t to current track
# reveal t



#KO reveal first item in albumTracks

#KO reveal playlist "Library"

#? reveal current track
#KO reveal (first item in albumTracks) of playlist "Library"

#KO reveal first item in albumTracks


(*OK set t to current track
reveal t *)
#OK reveal current track

# log name of view of (browser window 1)
#log name of view of (front browser window)

#
#set view of (browser window 1) to library playlist
#set view of (browser window 1) to library playlist 1

#set view of front browser window to library playlist 1


# set l to library playlist
# log l



# log name of l
#log parent of l
# log source of l


#log browser window
# set view of front browser window to playlist "Library"
#set view of front browser window to library playlist

# set view of front browser window to user playlist "Library" of source "Library"

#set selection to albumTracks
#browser window
end tell



Dumping ./iTunes Currently Playing Track/Speak Current Track.scpt 2010-04-23 23:10:43.623 osadecompile[34955:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
get player state
if player state is not paused and player state is not stopped then
tell current track
set message to "Now playing " & name & " of the album " & album & " from " & artist
end tell
tell AppleScript to say message using "Victoria" (* see http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as304.html *)
end if
end tell


Dumping ./iTunes Currently Playing Track/Volume/Decrease (-) Volume.scpt 2010-04-23 23:10:43.769 osadecompile[34958:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

set whatToDo to "dec" (* can be "inc", "dec", "mute" *)


(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)
set currentVolume to output volume of (get volume settings)
set scaledVolume to round (currentVolume / (100 / 16))

if (whatToDo contains "mute") then
set volume with output muted
else
if (whatToDo contains "inc") then
(* Use this code to increase the volume by a certain interval *)
set soundInterval to 1
set scaledVolume to scaledVolume + soundInterval
if (scaledVolume > 16) then
set scaledVolume to 16
end if
else if (whatToDo contains "dec") then
(* OR use this code to decrease the output volume by 1 *)
set scaledVolume to scaledVolume - 1
if (scaledVolume < 0) then
set scaledVolume to 0
end if
else
set scaledVolume to scaledVolume
end if

(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)
set newVolume to round (scaledVolume / 16 * 100)
set volume output volume newVolume

end if

Dumping ./iTunes Currently Playing Track/Volume/Increase (+) Volume.scpt 2010-04-23 23:10:43.887 osadecompile[34961:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

set whatToDo to "inc" (* can be "inc", "dec", "mute" *)


(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)
set currentVolume to output volume of (get volume settings)
set scaledVolume to round (currentVolume / (100 / 16))

if (whatToDo contains "mute") then
set volume with output muted
else
if (whatToDo contains "inc") then
(* Use this code to increase the volume by a certain interval *)
set soundInterval to 1
set scaledVolume to scaledVolume + soundInterval
if (scaledVolume > 16) then
set scaledVolume to 16
end if
else if (whatToDo contains "dec") then
(* OR use this code to decrease the output volume by 1 *)
set scaledVolume to scaledVolume - 1
if (scaledVolume < 0) then
set scaledVolume to 0
end if
else
set scaledVolume to scaledVolume
end if

(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)
set newVolume to round (scaledVolume / 16 * 100)
set volume output volume newVolume

end if

Dumping ./iTunes Currently Playing Track/Volume/Mute Volume.scpt 2010-04-23 23:10:43.992 osadecompile[34964:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

set whatToDo to "dec" (* can be "inc", "dec", "mute" *)


(* Get the current output volume (on a scale from 1 to 100) and convert it to a scale from 1 to 16 as seen when using the volume keys *)
set currentVolume to output volume of (get volume settings)
set scaledVolume to round (currentVolume / (100 / 16))

if (whatToDo contains "mute") then
set volume with output muted
else
if (whatToDo contains "inc") then
(* Use this code to increase the volume by a certain interval *)
set soundInterval to 1
set scaledVolume to scaledVolume + soundInterval
if (scaledVolume > 16) then
set scaledVolume to 16
end if
else if (whatToDo contains "dec") then
(* OR use this code to decrease the output volume by 1 *)
set scaledVolume to scaledVolume - 1
if (scaledVolume < 0) then
set scaledVolume to 0
end if
else
set scaledVolume to scaledVolume
end if

(* After using one of the above, the volume needs to be set to the new level (before which we must convert it back to the 1..100 scale) *)
set newVolume to round (scaledVolume / 16 * 100)
set volume output volume newVolume

end if

Dumping ./iTunes Currently Playing Track/Volume/Toggle Mute.scpt 2010-04-23 23:10:44.100 osadecompile[34967:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* Mute/Unute
*)
set _muted to (get (output muted of (get volume settings)))
if _muted is false then
set volume with output muted
else
set volume without output muted
end if

Dumping ./iTunes Selected Tracks/*****.scpt 2010-04-23 23:10:44.188 osadecompile[34970:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

repeat with aTrack in sel

set r to 5
set rating of aTrack to 100 / 5 * r

end repeat
end if
end tell

Dumping ./iTunes Selected Tracks/****.scpt 2010-04-23 23:10:44.308 osadecompile[34973:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

repeat with aTrack in sel

set r to 4
set rating of aTrack to 100 / 5 * r

end repeat
end if
end tell

Dumping ./iTunes Selected Tracks/***.scpt 2010-04-23 23:10:44.427 osadecompile[34976:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

repeat with aTrack in sel

set r to 3
set rating of aTrack to 100 / 5 * r

end repeat
end if
end tell

Dumping ./iTunes Selected Tracks/**.scpt 2010-04-23 23:10:44.540 osadecompile[34979:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

repeat with aTrack in sel

set r to 2
set rating of aTrack to 100 / 5 * r

end repeat
end if
end tell

Dumping ./iTunes Selected Tracks/*.scpt 2010-04-23 23:10:44.644 osadecompile[34982:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to rate " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

repeat with aTrack in sel

set r to 1
set rating of aTrack to 100 / 5 * r

end repeat
end if
end tell

Dumping ./iTunes Selected Tracks/Google Album Artwork Of Selected Track.scpt 2010-04-23 23:10:44.752 osadecompile[34985:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...
set sel to a reference to selection
if ((count of sel) > 1) then
activate
set res to display dialog "Are you sure you want Artwork for more than one track?" buttons {"I know what I'm doing", "Ah, no, thank you!"}
#if
log res
if button returned of res is not "I know what I'm doing" then
return
end if
end if
repeat with aTrack in sel
set tArtist to artist of aTrack
set tAlbum to album of aTrack
set queryText to "\"" & tArtist & "\" \"" & tAlbum & "\""
tell application "Safari"
activate
open location "http://google.com/images?q=" & queryText & ""
end tell
end repeat
end if
end tell



Dumping ./iTunes Selected Tracks/Google Lyrics Of Selected Track.scpt 2010-04-23 23:10:44.872 osadecompile[34988:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"

if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 1 or trackCount is less than 1 then
activate
set msg to "You selected " & trackCount & " tracks. Please select exactly one. Thanks a bunch."
set res to display dialog msg buttons {"Sure!"}
return
end if

set aTrack to first item in sel

set tArtist to artist of aTrack
set tName to name of aTrack
set queryText to "lyrics \"" & tArtist & "\" \"" & tName & "\""
set queryText to my replace_chars(queryText, "&", "%26") # see http://www.degraeve.com/reference/urlencoding.php

tell application "Safari"
activate
# open location "http://google.com/search?q='" & queryText & "'"
open location "http://google.com/search?q=" & queryText & ""
end tell

end if

end tell


# see http://forums.macosxhints.com/archive/index.php/t-26666.html
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars


Dumping ./iTunes Selected Tracks/Paste Selected iTunes Tracks with Album.scpt 2010-04-23 23:10:45.027 osadecompile[34991:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"

if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to do this with the selected " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

set message to ""
repeat with aTrack in sel

tell aTrack
set message to message & artist & " - " & album & " - " & name & return
end tell

end repeat

set the clipboard to message

tell application "System Events" to keystroke "v" using {command down}

end if
end tell


Dumping ./iTunes Selected Tracks/Paste Selected iTunes Tracks.scpt 2010-04-23 23:10:45.171 osadecompile[34994:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"

if selection is not {} then -- there ARE tracks selected...

set sel to a reference to selection
set trackCount to count sel
if trackCount is greater than 23 then
set msg to "Are you sure, you want to do this with the selected " & trackCount & " tracks?"
set res to display dialog msg buttons {"Sure!", "Actually, no."}
if button returned of res is not "Sure!" then
return
end if
end if

set message to ""
repeat with aTrack in sel

tell aTrack
set message to message & artist & " - " & name & return
end tell

end repeat

set the clipboard to message

tell application "System Events" to keystroke "v" using {command down}

end if
end tell


Dumping ./iTunes Selected Tracks/Play Single Track.scpt 2010-04-23 23:10:45.325 osadecompile[34997:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* 
Ever wondered how you can play a single track? Think of it: You navigate to a track in your music library, and you want to play it. Just this one.
Yes: iTunes offers no method of doing this (except creating a new playlist, adding the track, playing the track und deleting the playlist afterwards. Yes, this sucks).

The bad news: I have no better solution.
Now the good news: You don't have to do it yourself! Here's the script that does it all for you: (place into ~/Library/iTunes/Scripts/ or ~/Library/Scripts/)
*)

global tempplaylistname
on run
(* Init *)

set tempplaylistname to "temp"

(* Create new playlist, if not existing *)
tell me to set pl to newtempplaylist()

(* selected track -> pl *)
tell application "iTunes"

(* remember old playlist *)
set oldpl to view of (browser window 1)

(* Now the magic... *)
try
get class of selection
# log selection
# if ((count of selection) is greater than 0) then
set t to first item in selection

(* track into playlist *)
duplicate t to pl

(* playlist repeat off *)
set song repeat of pl to off

(* playlist to front *)
try
#set view of front window to playlist pl
#set view of browser window to pl
#set view of (browser window 1) to user playlist pl (*Fuck! (iTunes got an error: A descriptor type mismatch occurred.)*)
set view of (browser window 1) to pl (* Works with iTunes 9 *)
on error (e)
log "Fuck! (" & e & ")"
end try

(* play track *)
play first item of tracks of pl

(* Wait until track played or stopped *)
set dur to duration of t
repeat dur times
if player state is not playing then exit repeat
delay 1.0
end repeat

(* restore old playlist *)
set view of (browser window 1) to oldpl
on error (e)
display dialog "Select something, you weenie!" buttons "Yes, your highness!"
end try

(* delete temp playlist *)
delete pl
end tell
end run

(* Create a temp playlist we will delete afterwards *)
on newtempplaylist()
tell application "iTunes"
set pl to make new user playlist with properties {name:tempplaylistname & " as of " & (current date) as string}
end tell
return pl
end newtempplaylist

Dumping ./iTunes Selected Tracks/Remove Leading "01" from Title.scpt 2010-04-23 23:10:45.439 osadecompile[35000:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

tell application "iTunes"

tell application "iTunes"
if selection is not {} then -- there ARE tracks selected...
set sel to a reference to selection
repeat with aTrack in sel

set oldName to name of aTrack
log "Processing :" & oldName

set cmd to "echo \"" & oldName & "\" | sed s/01\\ //\\g"
tell application "Finder"
set newName to do shell script cmd
end tell
log "Setting new name: " & newName

set name of aTrack to newName

end repeat
end if
end tell

end tell

Dumping ./Leo Selected Text.scpt 2010-04-23 23:10:45.566 osadecompile[35003:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* Copy selected string to clipboard *)
tell application "System Events"
(* Try using Cmd-C *)
set oldClipboard to the clipboard
keystroke "c" using {command down}
set someword to the clipboard
if (oldClipboard is equal to someword) then
log "Most likely you held some more modifiers down (f.e. if you launch this script with FastScripts and a Shortcut that uses option, control or shift..)"
(* Trying to invoke "Copy" Menu command *)
set appName to name of current application
# my menu_click({appName, my menuEditLocalized(), my menuItemEditCopyLocalized(), ""})
tell application "System Events"
set procs to every process
repeat with p in procs
if frontmost of p is true then
set proc to p
end if
end repeat
#set proc to items of processes whose frontmost is true
#set proc to item 1 of processes
get proc
#click menu item "Copy" of ((proc)'s (menu bar 1)'s (menu bar item "Edit"))
set menuBar to menu bar 1 of proc
set editMenu to menu bar item whose name is (my menuEditLocalized())
return 0
end tell
end if
#delay 0.5
end tell


(* Open Browser with query *)
tell application "Safari"
activate
open location "http://dict.leo.org/?search='" & someword & "'"
end tell


(* get localized copy menu item name *)
on menuItemEditCopyLocalized()
tell AppleScript
set cmd to "defaults read NSGlobalDomain AppleLanguages | grep -v \"^(\" | grep -v \"^)\" | head -1 | cut -d, -f1 | awk '{printf $1}'"
set languageCode to do shell script cmd
if (languageCode is "de") then
return "Kopieren"
else if (languageCode is "en") then
return "Copy"
else
log "WTF?"
return ""
end if
end tell
end menuItemEditCopyLocalized


(* get localized copy menu name *)
on menuEditLocalized()
tell AppleScript
set cmd to "defaults read NSGlobalDomain AppleLanguages | grep -v \"^(\" | grep -v \"^)\" | head -1 | cut -d, -f1 | awk '{printf $1}'"
set languageCode to do shell script cmd
if (languageCode is "de") then
return "Bearbeiten"
else if (languageCode is "en") then
return "Edit"
else
log "WTF?"
return ""
end if
end tell
end menuEditLocalized




(* This came from http://www.macosxhints.com/article.php?story=20060921045743404 *)
on menu_click(mList)
local appName, topMenu, r

-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"

-- Set these variables for clarity and brevity later on
set {appName, topMenu} to (items 1 through 2 of mList)
set r to (items 3 through (mList's length) of mList)

-- This overly-long line calls the menu_recurse function with
-- two arguments: r, and a reference to the top-level menu
tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click

on menu_click_recurse(mList, parentObject)
local f, r

-- `f` = first item, `r` = rest of items
set f to item 1 of mList
if mList's length > 1 then set r to (items 2 through (mList's length) of mList)

-- either actually click the menu item, or recurse again
tell application "System Events"
if mList's length is 1 then
click parentObject's menu item f
else
my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
end if
end tell
end menu_click_recurse

Dumping ./Look Up Selected Text In Dictionary.scpt 2010-04-23 23:10:45.721 osadecompile[35006:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* Unfortunately Dictionary is not scriptable but can only be automated with Automator. However there is always the dirty way using System Events. That's what I did to script Dictionary.
*)

(* Get selected text *)
tell application "System Events" to keystroke "c" using {command down}

(* Bring Dictionary to foreground *)
tell application "Dictionary" to activate


(* Paste selected text *)
tell application "System Events" to keystroke "v" using {command down}


(* Look up *)
# tell application "System Events" to keystroke return




Dumping ./Paste Log Timestamp.scpt 2010-04-23 23:10:45.863 osadecompile[35009:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

on run (argv)
# set oldClip to the clipboard

set the clipboard to my timestamp()


tell application "System Events" to keystroke "v" using {command down}

# set the clipboard to oldClip
end run


(* get a time stamp *)
on timestamp()
set dateNow to current date
set dateYear to year of dateNow
set dateMonth to (month of dateNow as number)
set dateDay to addLeadingZeros(2, day of dateNow)
set dateHour to addLeadingZeros(2, hours of dateNow)
set dateMinute to addLeadingZeros(2, minutes of dateNow)
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & ", " & dateHour & ":" & dateMinute & ", hk: ") as string
end timestamp

(* Liefert von einer Zahl n leading zeros zurück *)
on addLeadingZeros(zeroesCount, value)

(* nimmt die letzten zeroesCount Stellen des Strings *)
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)
log "newNumber: " & newNumber

return (newNumber)
end addLeadingZeros



Dumping ./Paste Timestamp.scpt 2010-04-23 23:10:46.009 osadecompile[35012:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

set the clipboard to my timestamp()


tell application "System Events" to keystroke "v" using {command down}



(* get a time stamp *)
on timestamp()
set dateNow to current date
set dateYear to year of dateNow
set dateMonth to (month of dateNow as number)
set dateDay to addLeadingZeros(2, day of dateNow)
set dateHour to addLeadingZeros(2, hours of dateNow)
set dateMinute to addLeadingZeros(2, minutes of dateNow)
set dateString to (dateYear & "-" & dateMonth & "-" & dateDay & " " & dateHour & ":" & dateMinute) as string
end timestamp

(* Liefert von einer Zahl n leading zeros zurück *)
on addLeadingZeros(zeroesCount, value)

(* nimmt die letzten zeroesCount Stellen des Strings *)
set newNumber to (text -zeroesCount thru -1 of ("0000000000000000" & value)) (* Da musch drauf kommen: http://macscripter.net/viewtopic.php?id=24533 *)
log "newNumber: " & newNumber

return (newNumber)
end addLeadingZeros


Dumping ./Reply Mail With Quote.scpt 2010-04-23 23:10:46.166 osadecompile[35015:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osadecompile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

(* History:
2010-02-21, 16:44, hk: First version.
* If name contains "," reverse order!--DONE
* get original text--DONE
* check if already quoted, if not-> quote--DONE
* Leere Zeilen auch quoten--DONE
* Reply & set new content--DONE

Bug: Erkennung des schon gequoteten buggt!--?

ToDo:

*)


tell application "Mail"
# tell message viewer
# get selected messages
# end tell
set selectedMessages to selection
set selectedMessagesCount to (count selectedMessages)
if selectedMessagesCount > 0 then
if selectedMessagesCount > 23 then
set res to display dialog "Are you sure you want to reply on " & selectedMessagesCount & " messages?" buttons {"No", "Maybe", "Yes"}
if button returned of res is not "Yes" then
return
end if
end if
(* Now, do the magic! *)
repeat with selectedMessage in selectedMessages
tell selectedMessage
set smSender to sender
(* cut the email-address *)
tell me to set smSenderName to cutString of smSender by "<"
(* If name contains "," cut the part before the "," and add it at the end (this way "Doe, John" will get "JD" instead of "DJ") *)
if smSenderName contains "," then
log "foo"
tell me to set smSenderNameSurname to cutString of smSenderName by ","
log smSenderNameSurname
tell me to set smSenderNameFirstname to cutStringRemainder of smSenderName by ","
log smSenderNameFirstname
set smSenderName to (smSenderNameFirstname & " " & smSenderNameSurname) as text (* yes, that's ugly *)
log smSenderName
end if
(* get initials of the name *)
tell me to set smInitials to initialsOfName(smSenderName)
(* get text of mail and walk lines... http://www.mactech.com/articles/mactech/Vol.21/21.07/WorkingWithText/index.html *)
set smText to content
set smTextQuoted to ""
#log smText
#set smTextLineCount to count paragraphs of smText

(* Zeilen (=Paragraphs) abklappern *)
repeat with p in (paragraphs of smText)

(* Get line length *)
set lineLength to (length of p)
if lineLength > 5 then
set lineLength to 5
end if

if lineLength > 0 then
set pBegin to characters 1 thru lineLength of p
else
set pBegin to ""
end if

if pBegin contains ">" then
(* is quoted -> just concatenate strings *)
#log "already quoted: " & pBegin
set smTextQuoted to smTextQuoted & (p as string) & return
else

#if pBegin does not contain ">" then
(* not quoted yet, quote! *)
set smTextQuoted to smTextQuoted & smInitials & "> " & (p as string) & return
#else
# (* already quoted *)
# set smTextQuoted to smTextQuoted & (p as string) & return
#end if
#else
#set smTextQuoted to smTextQuoted & (p as string) & return
end if

end repeat (* repeat with paragraphs *)
log "quoted text: " & return & smTextQuoted
end tell # tell selectedMail

(* Backup quoting behaviour *)
tell application "Mail" to set quotingSetting to quote original message
tell application "Mail" to set quote original message to false

(* now reply *)
set newMessage to reply selectedMessage with opening window and reply to all
if newMessage is false then
log "Gee, reply failed."
else
tell newMessage
log newMessage
#set content of newMessage to "foo" -- smTextQuoted
# make new content with properties {text:"smTextQuoted"}
log (content)
log (subject)
log (sender)
log (to recipients)
#make new to recipient with properties {address:"MY ADDRESS"}
log (to recipients)
#make new content with t
#log "s: " & (contents as text)
set content to "foo"
set content to smTextQuoted
#make new content with properties {text:"MY text"}
end tell
end if # reply worked

(* Restore quoting behaviour *)
tell application "Mail" to set quote original message to quotingSetting

end repeat (* repeat with mails *)
else
log ("You might want to select a message first")
end if
end tell

(* Now get the first characters of every word (Initials) *)
on initialsOfName(sendername)
set initials to ""
repeat with oneWord in (words of sendername)
set initials to initials & first character of oneWord
end repeat
return initials
end initialsOfName

(* cuts all the text following the first occurance of the searchstring 'd' *)
to cutString of t by d
set oldd to text item delimiters
set text item delimiters to d
set t to t's text items
set t to first item in t
set text item delimiters to oldd
t
end cutString

(* returns what cutString has cut off! *)
to cutStringRemainder of t by d
set oldd to text item delimiters
set text item delimiters to d
set t to t's text items
set wordCount to count t
if (wordCount > 1) then
set t to items 2 through wordCount in t
end if
set text item delimiters to oldd
t
end cutStringRemainder

(* Diese Funktion ersetzt einen String innerhalb eines strings durch einen anderen String. Quelle: http://macscripter.net/viewtopic.php?id=13008 *)
to changeSubString of t from s to r
set d to text item delimiters
set text item delimiters to s
set t to t's text items
set text item delimiters to r
tell t to set t to beginning & ({""} & rest)
set text item delimiters to d
t
end changeSubString

HeiMac:Little Helpers Scripts heiko$