davidyannick Posted October 19, 2020 Share Posted October 19, 2020 I'm trying tto convert a python scipt to vex, is there a VEX equivalent to rfind (python) ? node = hou.pwd() geo = node.geometry() for prim in geo.prims(): path=prim.attribValue("name") newpath=path[:path.rfind("/")] prim.setAttribValue("name",newpath) Thanks Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted October 19, 2020 Share Posted October 19, 2020 Bonjour David, A quick Google Search gives this as the first result → find This gives the first occurrence instead of the last one. To find the last one, I would invert the string temporarily. Although it looks like you are trying to split a path to get the name of the file (or the last folder) There is the splitpath function that does just that. Hope that helps ! Quote Link to comment Share on other sites More sharing options...
davidyannick Posted October 20, 2020 Author Share Posted October 20, 2020 17 hours ago, Alain2131 said: Bonjour David, A quick Google Search gives this as the first result → find This gives the first occurrence instead of the last one. To find the last one, I would invert the string temporarily. Although it looks like you are trying to split a path to get the name of the file (or the last folder) There is the splitpath function that does just that. Hope that helps ! thanks it helps me a lot, I'm a complet noob in Python sorry Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.