I would like to know if it is possible to do a script that could add a space (or any other static character such as an underscore) in between words that are capitalized?
Example (a folder is named):
TheRockyMountains
to turn into:
The Rocky Mountains or The_Rocky_Mountains
Sorry if this is noob basics but I have been googling for days now with no results
tell application "Finder"
set theFolder to choose folder
set theName to name of theFolder
set theSpacer to space
set name of theFolder to (do shell script "/usr/bin/php -r \"echo preg_replace('/(?<=[a-z])(?=[A-Z])/','" & theSpacer & "','" & theName & "');\"")
end tell
one question … since I’ll be using this choosing multiple folders at a time is there a way to eliminate the “choose folder” prompt? I tried changing the line “set theFolder to choose folder” to “set theFolder to selection” but that didnt work.
tell application "Finder"
set theItems to selection
set theSpacer to space
repeat with anItem in theItems
set theName to name of anItem
set name of anItem to (do shell script "/usr/bin/php -r \"echo preg_replace('/(?<=[a-z])(?=[A-Z])/','" & theSpacer & "','" & theName & "');\"")
end repeat
end tell
I’ve been using Name Mangler for quite a few years now … I’m assuming you’re referring to using the advanced section … unfortunately I’m not grasping how to use NCDL. I’d love to but its just not clicking.
EDIT
Okay, I get what youre saying now … and it works … I would just like to understand how and why it works.