Batch file path changes?

   6586   15   5
User Avatar
Member
29 posts
Joined: Dec. 2016
Offline
Hi guys,

I had a project come in with a whole bunch of pre-built scenes complete with textures, and geo.
But, I need to update over a hundred file paths to their new locations. I found some ancient python scripts that may have worked at some point in the past, but don't seem to work anymore and my knowledge of Python isn't to the point where I can go through and try to debug them. There's also Pre-Flight, but it doesn't seem to be reading the directories correctly and is telling me that all of my files are missing when I can open the folder and see that the textures are where they should be. There also seems to be a bug where Pre-Flight just causes Houdini to crash entirely.

Any ideas?

Thanks in advance!
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
you can try the hscript command opchange
http://www.sidefx.com/docs/houdini/commands/opchange [www.sidefx.com]

it's old school and brute force - but it will get the job done.
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
408 posts
Joined: June 2015
Offline
this is so frustrating, i'm reading a bunch of posts where it all seems so simple to edit / replace paths in the hip file using opchange... buut truth is it just doesn't work.

i'm typing:

opchange D:/ASSETS/3D MODELS/STUFF/Downloaded/3d/ <space> $JOB/02_RESOURCES/STUFF/

Followed by enter. Which is pretty much whaat i've found in all related posts... and bam, "invalid use".

Notepad... word... have a "search and replace" tools... 3dsMax's asset manager allows to handle this kinda stuff easy... 3dsMAX fcs! 2021 and Houdini only have a CMD interface to do this stuff. I'm w asting hours on this cause i probably miss a "-WTV" or some "slash" or "backslash" somewhere and didn't watrch the 12 hours long houdini R13 TD masterclass from 2012... It's just too silly.

Anyways, I tried all the strings possible mentioned in the help file. it just won't find the strings in the file location fields.

Cheers,

A.
Edited by Adriano - April 28, 2021 01:54:48
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
Adriano
this is so frustrating, i'm reading a bunch of posts where it all seems so simple to edit / replace paths in the hip file using opchange... buut truth is it just doesn't work.

i'm typing:

opchange D:/ASSETS/3D MODELS/STUFF/Downloaded/3d/ <space> $JOB/02_RESOURCES/STUFF/

Followed by enter. Which is pretty much whaat i've found in all related posts... and bam, "invalid use".

It looks like you have a space in "3D MODELS" which will break your command. Put that first path in quotes to make it one option instead of what hscript thinks is 2 options.

You can also take advantage of text editors if you do File > Save As Text, then open the hip file in a text editor to do a search and replace.
User Avatar
Member
408 posts
Joined: June 2015
Offline
krueger
It looks like you have a space in "3D MODELS" which will break your command. Put that first path in quotes to make it one option instead of what hscript thinks is 2 options.


Already tried that... it does not work.

Houdini FX Version 18.5.499 (Compiled on Feb 25 2021)
/ -> opchange "D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/" $JOB/02_RESOURCES/MEGASCANS/
opchange: Invalid usage

/ -> opchange `D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/` $JOB/02_RESOURCES/MEGASCANS/
opchange: Invalid usage
opchange



Expression error: Syntax error - extra tokens detected in expression
/ -> opchange 'D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/' $JOB/02_RESOURCES/MEGASCANS/
opchange: Invalid usage
opchange


/ -> opchange "D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/" " $JOB/02_RESOURCES/MEGASCANS/"
Changing D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/ to D:/Dropbox/La Mer/02_RESOURCES/MEGASCANS/
No references to D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d/ found.
/ ->


The last one seems to have accepted the synthax, but it did not find anything nor change anything in the end. not cool SideFX... not cool.

krueger
You can also take advantage of text editors if you do File > Save As Text, then open the hip file in a text editor to do a search and replace.

Is that a Houdini "master" option? Cause i don't see that in my "file" roll down menu in Indie. I already looked into that as it's the easiest way imo to replace paths in AFX xml files. But i don't see the option to save my HIPs as text anywhere.

Cheers.
Edited by Adriano - April 28, 2021 22:50:47
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
Ok, opchange seems to be a little picky. I tried the first one you wrote and got the "No reference to..." response, but taking off the last "/" in each of the folder paths seems to fix it and it runs through the nodes. So putting your first folder in quotes, or putting both folders in quotes and making sure they don't end with a "/" should hopefully fix it for you.

Adriano
krueger
You can also take advantage of text editors if you do File > Save As Text, then open the hip file in a text editor to do a search and replace.

Is that a Houdini "master" option? Cause i don't see that in my "file" roll down menu in Indie. I already looked into that as it's the easiest way imo to replace paths in AFX xml files. But i don't see the option to save my HIPs as text anywhere.

Cheers.

It looks like that is a full version feature, my apprentice version at home doesn't have that option.
User Avatar
Member
408 posts
Joined: June 2015
Offline
krueger
Ok, opchange seems to be a little picky. I tried the first one you wrote and got the "No reference to..." response, but taking off the last "/" in each of the folder paths seems to fix it and it runs through the nodes. So putting your first folder in quotes, or putting both folders in quotes and making sure they don't end with a "/" should hopefully fix it for you.

Adriano
krueger
You can also take advantage of text editors if you do File > Save As Text, then open the hip file in a text editor to do a search and replace.

Is that a Houdini "master" option? Cause i don't see that in my "file" roll down menu in Indie. I already looked into that as it's the easiest way imo to replace paths in AFX xml files. But i don't see the option to save my HIPs as text anywhere.

Cheers.

It looks like that is a full version feature, my apprentice version at home doesn't have that option.

Thanks a bunch for looking into it. I'll give it a try first thing in the morning.

Cheers,

A.
User Avatar
Member
408 posts
Joined: June 2015
Offline
Thanks again, that did it. That opchange function is indeed picky but when it works it's a useful one. it Went through the entire scene in less than a second and relinked everything.

One thing i notice though is when i rename the path to $JOB... it's evaluating the $JOB instead of just writing it down. We're using deadline render mmanagement and we need to use the $JOB for it. Any idea how to force the $JOB alias instead of the location it references to?

Cheers,

A.
Edited by Adriano - April 29, 2021 13:46:51
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
Yeah, I noticed that too. I use more python than hscript, but it looks like you can use an escape "\" in front of $JOB so it doesn't evaluate it as a variable.

opchange "D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d" \$JOB/02_RESOURCES/MEGASCANS
User Avatar
Member
408 posts
Joined: June 2015
Offline
krueger
Yeah, I noticed that too. I use more python than hscript, but it looks like you can use an escape "\" in front of $JOB so it doesn't evaluate it as a variable.

opchange "D:/ASSETS/3D MODELS/Quixel_Megascan_Collection/Downloaded/3d" \$JOB/02_RESOURCES/MEGASCANS

Awesome, that indeed works. Thanks so much!

Cheers,

A.
User Avatar
Member
31 posts
Joined: Feb. 2018
Offline
Hi, thank you for solution in this thread to help solved my similar problem. I just follow and success batch change my HIP file for network deploy

My issue:
Everything currently store here: //<network>/projects/Explosion, all of the material now has texture in $HIP where filename path is

opchange -p /obj/mat_Environment/mGrid \$HIP \$JOB 

It works perfectly, please note "\" in front of $HIP and $JOB, without that it changed into the network full path. Without the splash at end of the folder work perfectly.
/obj/mat_Environment/mGrid/ Cchanged to /obj/mat_Environment/mGrid
Edited by paranoidx - June 18, 2021 03:15:57
User Avatar
Member
172 posts
Joined: Jan. 2014
Offline
Would be nice to have a UI solution for this. Env artists really miss this feature.
I contribute to the beauty of this world
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
I put this together real quick if anyone wants to use it. Just put it in your python2.7libs folder and just make a shelf tool with this code:

import mkParameterFindAndReplace

mkParameterFindAndReplace.launch()

Edit: I forgot to mention you can use it to expand variables if you want too. ie: putting $JOB in the find and also replace fields and checking the "Expand Variables When Replacing" checkbox will replace $JOB with the expanded folder.
Edited by krueger - June 24, 2021 00:11:25

Attachments:
mkParameterFindAndReplace.png (10.1 KB)
mkParameterFindAndReplace.pyc (4.3 KB)

User Avatar
Member
1 posts
Joined: June 2021
Offline
krueger
I put this together real quick if anyone wants to use it. Just put it in your python2.7libs folder and just make a shelf tool with this code:

import mkParameterFindAndReplace

mkParameterFindAndReplace.launch()

Edit: I forgot to mention you can use it to expand variables if you want too. ie: putting $JOB in the find and also replace fields and checking the "Expand Variables When Replacing" checkbox will replace $JOB with the expanded folder.

Thank you. Looks super useful. Gonna try it out.

One thing though it has to be placed into lib folder and not libs.
User Avatar
Member
408 posts
Joined: June 2015
Offline
krueger
I put this together real quick if anyone wants to use it. Just put it in your python2.7libs folder and just make a shelf tool with this code:

import mkParameterFindAndReplace

mkParameterFindAndReplace.launch()

Edit: I forgot to mention you can use it to expand variables if you want too. ie: putting $JOB in the find and also replace fields and checking the "Expand Variables When Replacing" checkbox will replace $JOB with the expanded folder.

You rock! Awesome.
User Avatar
Member
31 posts
Joined: Feb. 2018
Offline
krueger
I put this together real quick if anyone wants to use it. Just put it in your python2.7libs folder and just make a shelf tool with this code:

import mkParameterFindAndReplace

mkParameterFindAndReplace.launch()

Edit: I forgot to mention you can use it to expand variables if you want too. ie: putting $JOB in the find and also replace fields and checking the "Expand Variables When Replacing" checkbox will replace $JOB with the expanded folder.
thank you, you saved the day
Edited by paranoidx - Aug. 20, 2021 00:14:13
  • Quick Links