Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Benjamindaines

macrumors 68030
Original poster
Mar 24, 2005
2,841
4
A religiously oppressed state
I have a script for Adium but it saves to and iPod, I want it to save to the desktop. Here is a copy of the script. Please edit it to make it save to the desktop.

Code:
--made by leifh
--code from apple.com, macscripter.net
global volumes_directory, c
substitute("Annelise Conversation")
on substitute(docname)
	tell application "Adium"
		display dialog "What kind of note do you want?" buttons {"Blank", "Conversation"}
		set tpe to button returned of result
		set the mounted_iPods to my locate_iPods()
		if the mounted_iPods is {} then
			return "No iPod is connected to this computer."
		else if the (count of the mounted_iPods) is greater than 1 then
			return "Make sure only one iPod is connected to this computer."
		else
			set this_iPod to item 1 of the mounted_iPods
		end if
	end tell
	---------
	
	if tpe is "blank" then
		tell application "Adium"
			display dialog docname default answer "" & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return buttons {"Cancel", "Save"}
			set input to {button returned of result, text returned of result} as list
		end tell
		set fold to volumes_directory & this_iPod & "Notes:"
		if item 1 of input is "Save" then
			set f to paragraph 2 of "
" & (fold) & docname
			open for access file f with write permission
			write "" & (item 2 of input) to file f
			close access file f
			return docname & " has been saved to your iPod."
		end if
	else if tpe is "conversation" then
		---
		tell application "Finder"
			set a to (folder "Library" of (path to home folder))
			set a to (folder "Application Support" of a)
			set a to (folder "Adium 2.0" of a)
			set a to (folder "Users" of a)
			set a to (folder "Default" of a)
			set a to (folder "Logs" of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your screenname:") as string
			if b is "false" then error number -128
			set a to (folder b of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your buddy:") as string
			if b is "false" then error number -128
			set a to (folder b of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your conversation:") as string
			if b is "false" then error number -128
			set a to (file b of a) as alias
			open for access a with write permission
			set c to (read a) as string
			close access a
		end tell
		---
		if (b as string) contains "html" then
			set c to my snr(c, "Ôªø", "")
			set c to my snr(c, "<div class=\"receive\">", "")
			set c to my snr(c, "<div class=\"send\">", "")
			set c to my snr(c, "<span class=\"timestamp\">", "")
			set c to my snr(c, "</span>", "")
			set c to my snr(c, "<span class=\"sender\">", "")
			set c to my snr(c, "<pre class=\"message\">", "")
			set c to my snr(c, "<FONT>", "")
			set c to my snr(c, "</pre>", "")
			set c to my snr(c, "</div>", "")
			set c to my snr(c, "<div class=\"status\">", "")
			set c to my snr(c, "<I>", "")
			set c to my snr(c, "</I>", "")
			set c to my snr(c, "<B>", "")
			set c to my snr(c, "</B>", "")
			set c to my snr(c, "<U>", "")
			set c to my snr(c, "</U>", "")
			set c to every paragraph of c
			set c to my list_to_string(c, return & return) as string
		end if
		set fold to volumes_directory & this_iPod & "Notes:"
		set f to paragraph 2 of "
" & (fold) & docname
		open for access file f with write permission
		write c to file f
		close access file f
		return docname & " has been saved to your iPod."
	else
		return "Error."
	end if
end substitute
---------
on locate_iPods()
	set the volumes_directory to "/Volumes/" as POSIX file as alias
	set the volume_names to list folder volumes_directory without invisibles
	set mounted_iPods to {}
	repeat with i from 1 to the count of volume_names
		try
			set this_name to item i of volume_names
			set this_disk to ("/Volumes/" & this_name & "/") as POSIX file as alias
			set these_items to list folder this_disk
			if "iPod_Control" is in these_items then
				set the end of the mounted_iPods to this_disk
			end if
		end try
	end repeat
	return mounted_iPods
end locate_iPods
on list_to_string(the_list, the_delim)
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, the_delim}
		set {the_list, contents} to {"" & the_list, old_tid}
	end tell
end list_to_string
on snr(the_string, search_string, replace_string)
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, search_string}
		set {the_string, contents} to {the_string's text items, replace_string}
		set {the_string, contents} to {"" & the_string, old_tid}
	end tell
	return the_string
end snr

--Thanks so much
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
You'll probably get better answers in the Programming section of the forums.

Anyway, I believe the following will do what you want:

Code:
--made by leifh
--code from apple.com, macscripter.net
--code modified slightly by mduser63
global volumes_directory, c
substitute("Annelise Conversation")
on substitute(docname)
	tell application "Adium"
		display dialog "What kind of note do you want?" buttons {"Blank", "Conversation"}
		set tpe to button returned of result
	end tell
	---------
	
	if tpe is "blank" then
		tell application "Adium"
			display dialog docname default answer "" & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return & return buttons {"Cancel", "Save"}
			set input to {button returned of result, text returned of result} as list
		end tell
		tell application "Finder"
			set fold to (folder "Desktop" of (path to home folder))
		end tell
		if item 1 of input is "Save" then
			set f to paragraph 2 of "
" & (fold) & docname
			open for access file f with write permission
			write "" & (item 2 of input) to file f
			close access file f
			return docname & " has been saved to your iPod."
		end if
	else if tpe is "conversation" then
		---
		tell application "Finder"
			set a to (folder "Library" of (path to home folder))
			set a to (folder "Application Support" of a)
			set a to (folder "Adium 2.0" of a)
			set a to (folder "Users" of a)
			set a to (folder "Default" of a)
			set a to (folder "Logs" of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your screenname:") as string
			if b is "false" then error number -128
			set a to (folder b of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your buddy:") as string
			if b is "false" then error number -128
			set a to (folder b of a) as alias
			set b to (choose from list (list folder a without invisibles) with prompt "Choose your conversation:") as string
			if b is "false" then error number -128
			set a to (file b of a) as alias
			open for access a with write permission
			set c to (read a) as string
			close access a
		end tell
		---
		if (b as string) contains "html" then
			set c to my snr(c, "Ôªø", "")
			set c to my snr(c, "<div class=\"receive\">", "")
			set c to my snr(c, "<div class=\"send\">", "")
			set c to my snr(c, "<span class=\"timestamp\">", "")
			set c to my snr(c, "</span>", "")
			set c to my snr(c, "<span class=\"sender\">", "")
			set c to my snr(c, "<pre class=\"message\">", "")
			set c to my snr(c, "<FONT>", "")
			set c to my snr(c, "</pre>", "")
			set c to my snr(c, "</div>", "")
			set c to my snr(c, "<div class=\"status\">", "")
			set c to my snr(c, "<I>", "")
			set c to my snr(c, "</I>", "")
			set c to my snr(c, "<B>", "")
			set c to my snr(c, "</B>", "")
			set c to my snr(c, "<U>", "")
			set c to my snr(c, "</U>", "")
			set c to every paragraph of c
			set c to my list_to_string(c, return & return) as string
		end if
		tell application "Finder"
			set fold to (folder "Desktop" of (path to home folder))
		end tell
		set f to paragraph 2 of "
" & (fold) & docname
		open for access file f with write permission
		write c to file f
		close access file f
		return docname & " has been saved to your Desktop."
	else
		return "Error."
	end if
end substitute
---------
on list_to_string(the_list, the_delim)
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, the_delim}
		set {the_list, contents} to {"" & the_list, old_tid}
	end tell
end list_to_string
on snr(the_string, search_string, replace_string)
	tell (a reference to my text item delimiters)
		set {old_tid, contents} to {contents, search_string}
		set {the_string, contents} to {the_string's text items, replace_string}
		set {the_string, contents} to {"" & the_string, old_tid}
	end tell
	return the_string
end snr
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.