I'm wondering if it's possible when using Search and Replace Variable to delete any characters after a defined character. For example, I have filenames that are:
BASS#001.wav
STRINGS#001.wav
GUITAR A#001.wav
and I'd like to eliminate the "#" and anything that might come after that character to result in this:
BASS.wav
STRINGS.wav
GUITAR A.wav
I've included the relevant parts of the macro so far. Thanks for any help you can give.
Fortunately this is very easy with a bit of regex. Make sure the Search and Replace Variable action is set to search for a regular expression, and use this for the search:
Thank you so much for your help. It works like a charm!
I added the slash before %path% because I’d seen it in another post and don’t have much of an idea what I’m doing. Can you tell me why one would use the forward slash? Thanks.
No problem! Glad it did the trick. You would only want to add a forward slash in a file path to make sure that the path was read correctly. In other words,
Users/Documents/file.txt
is not a valid path because it lacks a forward slash at the beginning. In those cases, you would need add an initial forward slash to make it
/Users/Documents/file.txt
to make it valid and have it work as intended. Fortunately, when saving a file path to a variable, which is what you’re doing with the Finder’s selection in the For Each action, the entire path, complete with initial forward slash, is captured, so there’s no need to add a slash before the %path% variable. In fact, doing so would result in
//Users/Documents/file.txt
which is also not a valid path and would end up causing problems. Hope that all made sense!
You’re quite welcome. KM can definitely be daunting at first, but it’s perfectly okay, and even recommended, to start small and automate simple tasks as you get more familiar with its capabilities. Good luck, and don’t be afraid to ask more questions here if you get stuck!