Is there a simple script that will capitalize the first letter of every word in a file name? For example, change “This is my file.txt” to “This Is My File.txt”.
Hi,
the easiest way is to use a shell scrpt
set a to "This is my file.txt"
do shell script "/bin/echo " & quoted form of a & " | /usr/bin/awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'"
Thanks for the quick reply. I know I’m going to slap my forehead when I see the answer, but how do I set the new name to the results of the shell script?
set oldName to "This is my file.txt"
set newName to do shell script "/bin/echo " & quoted form of oldName & " | /usr/bin/awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'"