I have a null, with some string parameter. The first is a file directory parameter im using to get file paths and update them quickly.
Is there a way in hscript to take just the last folder name from this string, and generate a new parameter from that?
Example:
directory-- D:/MEGASCANS_LIBRARY/Downloaded/surface/stone_floor_vixidai
extracted string one--stone_floor_vixidai
extracted string two--vixidai
the first part of the string
D:/MEGASCANS_LIBRARY/Downloaded/surface/---will never change. its just that last path.
Thank you!
Ive attached an image which should make it clear.
Thanks!!!
Extract folder name from full file path in hscript?
2078 4 1- jtk700cln
- Member
- 49 posts
- Joined: 1月 2016
- Offline
- mestela
- Member
- 1749 posts
- Joined: 5月 2006
- Offline
Hscript gives you a handful of path modifiers:
https://www.sidefx.com/docs/houdini/commands/_guide.html#modifiers [www.sidefx.com]
But often its not quite what you need, and by the time you've backticked and text stripped and whatever else, the expression has become an unreadable mess.
Python is usually a better fit for these kind of things.
https://www.sidefx.com/docs/houdini/commands/_guide.html#modifiers [www.sidefx.com]
But often its not quite what you need, and by the time you've backticked and text stripped and whatever else, the expression has become an unreadable mess.
Python is usually a better fit for these kind of things.
- Alexander_Nguyen
- Member
- 21 posts
- Joined: 1月 2018
- Offline
I know you want to do it in hscript . But i only can do that in python . Hope it helpful with you .
// in wrangle
s@path = "D:/MEGASCANS_LIBRARY/Downloaded/surface/stone_floor_vixidai";
s@path_01 = "";
s@path_02 = "";
In Python :
node = hou.pwd()
geo = node.geometry()
path = geo.attribValue("path")[::-1]
path_final = ""
path_final_02 = ""
for element in range(0,len(path)):
if ( (path[element]) != "/" ):
path_final += path[element]
elif ( (path[element]) == "/" ):
break
geo.setGlobalAttribValue("path_01",path_final[::-1])
for element in range(0,len(path_final)):
if ( (path_final[element]) != "_" ):
path_final_02 += path_final[element]
elif ( (path_final[element]) == "_" ):
break
geo.setGlobalAttribValue("path_02",path_final_02[::-1])
Edited by Alexander_Nguyen - 2022年5月18日 10:55:21
- jtk700cln
- Member
- 49 posts
- Joined: 1月 2016
- Offline
- tamte
- Member
- 8635 posts
- Joined: 7月 2007
- Offline
I'd go with Python only if it's an expression as mestela suggested
if you go with detail attribs then a single Detail wrangle should be enough:
if you go with detail attribs then a single Detail wrangle should be enough:
string path = "D:/MEGASCANS_LIBRARY/Downloaded/surface/stone_floor_vixidai"; splitpath(path, s@dir, s@filename); s@suffix = split(s@filename, "_")[-1];
Edited by tamte - 2022年5月18日 19:20:44
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
-
- Quick Links