# Opcode FileNameFromPath alternative

**URL:** <https://forum.cabbageaudio.com/t/opcode-filenamefrompath-alternative/3005>\
**Category:** Cabbage recipes\
**Created:** [30 December 2021 00:04 UTC](https://forum.cabbageaudio.com/t/opcode-filenamefrompath-alternative/3005 "2021-12-30T00:04:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aspanoz](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/aspanoz/32/3876_2.png) [@aspanoz](https://forum.cabbageaudio.com/u/aspanoz)\
**Post date:** [30 December 2021 00:04 UTC](https://forum.cabbageaudio.com/t/opcode-filenamefrompath-alternative/3005/1 "2021-12-30T00:04:41Z")

</div>

opcode FileNameFromPath, S, S  
S\_path xin  
i\_pos strrindex S\_path, “/”  
S\_name strsub S\_path, i\_pos + 1  
xout S\_name  
endop

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [30 December 2021 10:04 UTC](https://forum.cabbageaudio.com/t/opcode-filenamefrompath-alternative/3005/2 "2021-12-30T10:04:20Z")

</div>

Hi @aspanoz, thanks for posting this, and welcome to the forum. It’s always nice to have native Csound implementations of these things. 👍

---

<div class="post-metadata">

**Author:** ![aspanoz](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/aspanoz/32/3876_2.png) [@aspanoz](https://forum.cabbageaudio.com/u/aspanoz)\
**Post date:** [13 January 2022 10:52 UTC](https://forum.cabbageaudio.com/t/opcode-filenamefrompath-alternative/3005/3 "2022-01-13T10:52:46Z")

</div>

The original function FileNameFromPath did not calculate the filename correctly in osx 🙂 And thank you for your titanic work!
