Last active
January 9, 2024 05:46
-
-
Save cazepeda/55a0644c5ef0d2db7b19402d331709ef to your computer and use it in GitHub Desktop.
Applescript to convert spaces, @, ?, ', to hyphens and uppercase to lowercase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input} | |
set input to replaceText(" ", "-", input as string) | |
set input to replaceText(".", "", input as string) | |
set input to replaceText(":", "", input as string) | |
set input to replaceText(",", "", input as string) | |
set input to replaceText("@", "at", input as string) | |
set input to replaceText("'", "", input as string) | |
set input to replaceText("&", "and", input as string) | |
set input to replaceText("?", "", input as string) | |
set input to do shell script "echo " & quoted form of input & " | tr '[:upper:]' '[:lower:]'" | |
end run | |
on replaceText(find, replace, textString) | |
set prevTIDs to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to find | |
set textString to text items of textString | |
set AppleScript's text item delimiters to replace | |
set textString to "" & textString | |
set AppleScript's text item delimiters to prevTIDs | |
return textString | |
end replaceText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment