Smart Title Capitalization of Title Via AppleScript - Possible Feature Request

This is what I call “smart title capitalization” of the title using a AppleScript.

I often find I will copy text from the description other sources into the title and it needs to be capitalized.

If you do a traditional bulk capitalization of the title you have to go back and edit words that should not be capitalized. Manually capitalizing select words also wastes times.

This script stores a list of of word that should not be capitalized.

This could be added as a feature by storing one or more similar lists within GS and referencing them in a similar fashion to Text Snippets.

I export this AppleScript as a app and store it on the edge of one of my screens, just off the side of GS, I can quickly double click it and go back to GS.

This AppleScript specifically mentions “GarageSale 9.8.1” so you may need to change that to “GarageSale” or something else depending on your setup. I have multiple different versions of GS installed and I rename each to include the version in the name thus the AppleScripts I have use must reference specific versions.

set NoCapList to {"a", "and", "as", "at", "but", "by", "down", "for", "from", "if", "in", "into", "like", "near", "nor", "of", "off ", "on", "once", "onto", "or", "over", "past", "so", "than", "that", "to", "upon", "when", "with", "yet"} --Set List of Non Capitalized Words

tell application "GarageSale 9.8.1"
	repeat with theListing in (get selected ebay listings)
		set des to get the title of theListing
		
		set tempTitle to my titlecase(des)
		
		set AppleScript's text item delimiters to " "
		set TitleList to text items of tempTitle
		
		repeat with TitleIndex from 1 to count of TitleList --Loop Through TitleList Words	
			
			repeat with NoCapIndex from 1 to count of NoCapList --Loop Through NoCapList
				
				if item TitleIndex of TitleList is equal to item NoCapIndex of NoCapList then --Matches NoCapWord
					
					set item TitleIndex of TitleList to item NoCapIndex of NoCapList --Replace with Lower Case Version
					
				else if item TitleIndex of TitleList is not equal to item NoCapIndex of NoCapList then --Does Not Match NoCapWord
					
					--Do Nothing
					
				end if
				
			end repeat
			
		end repeat
		
		set AppleScript's text item delimiters to " "
		set NewTitleText to TitleList as string
		set the title of theListing to NewTitleText
		
	end repeat
end tell

on titlecase(txt)
	--return do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of txt
	set titleCaseString to (do shell script "/bin/echo" & space & quoted form of txt & space & "| /usr/bin/perl -p -e 's/(\\w+)/\\u\\L$1/g;'") as Unicode text
end titlecase

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.