Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: A simple way to copy the path to a file or folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A simple way to copy the path to a file or folder
Authored by: regulus on Oct 22, '07 11:24:47PM
That's a very simple task. You use applescript's text item delimiters. Using your example, if you want to change /Volumes/E-TEST$/KaleidaScope2006/wwwroot/index.asp to /Volumes/E$/KaleidaScope2006/wwwroot/index.asp, then you want to replace /Volumes/E-TEST$ with /Volumes/E$. Here's a simple search/replace routine for you. And if you want to get the selected items path see my post above.
set myString to "/Volumes/E-TEST$/KaleidaScope2006/wwwroot/index.asp"
set search_string to "/Volumes/E-TEST$"
set replacement_string to "/Volumes/E$"

my findReplace(myString, search_string, replacement_string)



(*============ SUBROUTINE ==============*)
on findReplace(theString, search_string, replacement_string)
	repeat
		if theString contains search_string then
			set AppleScript's text item delimiters to search_string
			set the text_item_list to text items of theString
			set AppleScript's text item delimiters to replacement_string
			set the theString to every item in text_item_list as Unicode text
			set AppleScript's text item delimiters to ""
		else
			exit repeat
		end if
	end repeat
	return theString
end findReplace


[ Reply to This | # ]
10.4: A simple way to copy the path to a file or folder
Authored by: regulus on Oct 22, '07 11:26:41PM

Oops, take out the repeat/end repeat statements from the subroutine... they're not needed.



[ Reply to This | # ]
10.4: A simple way to copy the path to a file or folder
Authored by: regulus on Oct 22, '07 11:35:00PM
And if you want to get a whole applescript together, the folks over at the MacScripter forums are always willing to help... http://bbs.applescript.net/viewforum.php?id=2

[ Reply to This | # ]
10.4: A simple way to copy the path to a file or folder
Authored by: bvdecicco on Oct 23, '07 06:25:54AM

Thanks so much for the help. This will be such a great little script to have available once I get it all together.

Thank you, thank you!



[ Reply to This | # ]
10.4: A simple way to copy the path to a file or folder
Authored by: regulus on Oct 23, '07 03:38:12PM

No problem.



[ Reply to This | # ]