Cabbage Logo
Back to Cabbage Site

Split string?

Say you have a path: C:\Users\Test\File.mp3, and want to split the string:

"C:\Users\Test\File.mp3"

at the last slash to

"File.mp3"

Does anyone know how to achieve this in Csound?

strsub is probably the way to do this.
https://csound.com/docs/manual/strsub.html
Although, to know where to split the string you’ll need to work back though it and find the location of the final ‘’. For that you can use strchar:
https://csound.com/docs/manual/strchar.html

1 Like

You an also use the cabbageGetFile utility opcode.

1 Like

Nice! I think I made some elaborate UDO for this a while back and there you go and write an opcode that does it all!