Hi…
I’ve got a little problem.
I want AppleScript to change a string like “i go out tonight” to “I Go Out Tonight”, so that the first letter of every word is a capital. Any idea how I could do this?
Greets and thanks
nicki
Hi…
I’ve got a little problem.
I want AppleScript to change a string like “i go out tonight” to “I Go Out Tonight”, so that the first letter of every word is a capital. Any idea how I could do this?
Greets and thanks
nicki
set thetext to "i go out tonight"
do shell script "echo " & quoted form of thetext & " | /usr/bin/ruby -e \"puts STDIN.read.gsub(/^[a-z]|\\s+[a-z]/) { |a| a.upcase }\""
--"I Go Out Tonight"
See also:
http://bbs.macscripter.net/viewtopic.php?id=13297
http://bbs.macscripter.net/viewtopic.php?id=12758
.or the python version
set thetext to "i go out tonight"
do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of thetext
Thank you very much!!! You helped me a lot!
nicki