Beware -- as written this will nuke file extensions too. Easy enough to add them back when building the new name, though -- change the set newName...
line to:
set newName to text 1 thru ((offset of " - " in oldName) - 1) of oldName & "." & name extension of theItem
You can do more general solutions than @skillet's using "standard" KM actions -- the route you take will depend on what you are trying to do.
For one-shotting multiple lines, the easiest is to "Search and Replace Variable", deleting everything from " - " to the end of each line. You'll need a regular expression since you don't know exactly what "until the end of the line" might contain:
Block Trim.kmmacros (3.1 KB)
If you are working on one item at a time -- either because there is only one item or you are doing this in a "For Each" action -- you can instead "capture" the text before " - ". Since the divider is a constant, the easiest way is to treat the text as a pseudo array using a custom delimiter, grabbing the first element:
Item Trim (Array).kmmacros (3.6 KB)
Or you can use the "Search Using Regular Expression" action -- useful for when your "divider" can vary -- this, for example copes with one or more dashes in the divider. (And notice that it ignores the hyphenated word because there are no spaces. The others do to, I just forgot to include it!):
Item Trim (RegEx).kmmacros (4.2 KB)
Main thing to watch out for with that is to turn off "on failure" options if you'll have un-dashed items in your list:
If you're doing file renaming, these can all be combined with KM's "Move or Rename a File" action. This, for example, will rename Finder-selected items of the form:
MAINFILE - REGION.mp3
Another File - Something.txt
...to:
MAINFILE (DONE).mp3
Another File (DONE).txt
Name Change in Place.kmmacros (2.3 KB)
...although you'll probably want some error checking!
There's a bucket-load of ways to do this sort of thing -- have a search of the Forum for more ideas.