Easiest way to convert ~500 '.obj' files to '.bgeo'?
7168 11 4- KalciferKandari
- Member
- 48 posts
- Joined: Feb. 2017
- Offline
- mark
- Staff
- 2641 posts
- Joined: July 2005
- Offline
- cwhite
- Staff
- 750 posts
- Joined: Oct. 2012
- Offline
- KalciferKandari
- Member
- 48 posts
- Joined: Feb. 2017
- Offline
- Oluf Andrews
- Member
- 9 posts
- Joined: April 2015
- Offline
- KalciferKandari
- Member
- 48 posts
- Joined: Feb. 2017
- Offline
- Oluf Andrews
- Member
- 9 posts
- Joined: April 2015
- Offline
- KalciferKandari
- Member
- 48 posts
- Joined: Feb. 2017
- Offline
- nicoM
- Member
- 74 posts
- Joined:
- Offline
- KalciferKandari
- Member
- 48 posts
- Joined: Feb. 2017
- Offline
Thank you very much, the script worked. Here is a more friendly version for others to see:
Copy and paste this to a text file and save as a ‘.py’ instead of ‘.txt’. Be warned, this will overwrite existing ‘.bgeo’ files if they have the same name as the ‘.obj’ file.
Copy and paste this to a text file and save as a ‘.py’ instead of ‘.txt’. Be warned, this will overwrite existing ‘.bgeo’ files if they have the same name as the ‘.obj’ file.
# Converts all the '.obj' files in a folder to '.bgeo' files, using the # 'gconvert' Houdini command, as such this script requires Houdini to be # installed. # Run using 'Command Line Tools' on Windows, and 'Houdini Terminal' on # OSX. import sys, os folder = "." # If the script is in another folder to the '.obj' files, put # the path in this string. for file in os.listdir(folder): if file.endswith('.obj'): path = folder + "/" + file geo = folder + "/" + file.replace('.obj', '.bgeo') command = 'gconvert %s %s' % (path, geo) print(command) if os.system(command): print('Error running command.') break
Edited by KalciferKandari - March 23, 2017 14:39:44
- blackpixel
- Member
- 182 posts
- Joined: April 2009
- Online
If you're on Windows, then you can create a simple batch script and put it in your “Send To” rightclick menu ( On windows 7 at least ).
Hit the windows key and type shell:sendto
It should open a folder >> C:\Users\your.username\AppData\Roaming\Microsoft\Windows\SendTo
Create a new textfile like _convert_to_bgeo, rename .txt to .bat and edit it:
( also change the path to your gconvert.exe )
Now select your OBJ files and right click > Send To > _convert_to_bgeo.bat.
Your files will now be converted one by one to bgeo.sc.
If you take out the /WAIT then it will launch a new process for each file.
This might be a bad idea with 500 files, but it's certainly faster if you have the resources.
You can do the same thing with textures to .rat files with iconvert.exe
Hit the windows key and type shell:sendto
It should open a folder >> C:\Users\your.username\AppData\Roaming\Microsoft\Windows\SendTo
Create a new textfile like _convert_to_bgeo, rename .txt to .bat and edit it:
( also change the path to your gconvert.exe )
@echo off
for %%i in (%*) do (
echo "converting %%~ni to bgeo.sc ..."
START /WAIT "" "C:\Program Files\Side Effects Software\Houdini 16.0.556\bin\gconvert.exe" "%%~nxi" "%%~dpi\%%~ni.bgeo.sc"
echo "done."
)
Now select your OBJ files and right click > Send To > _convert_to_bgeo.bat.
Your files will now be converted one by one to bgeo.sc.
If you take out the /WAIT then it will launch a new process for each file.
This might be a bad idea with 500 files, but it's certainly faster if you have the resources.
You can do the same thing with textures to .rat files with iconvert.exe
Edited by blackpixel - March 25, 2017 03:02:04
- JH12345
- Member
- 11 posts
- Joined: April 2018
- Offline
Apologies for reviving an old thread here. I'm wondering if it would be possible to amend this script to make it work inside a series of folders, not just a single directory?
I have a workflow which will generate a large series of folders with .obj sequences inside each - is there a way I can make this script look inside each subfolder and make the conversion to everything in one go?
Thanks for any advice
I have a workflow which will generate a large series of folders with .obj sequences inside each - is there a way I can make this script look inside each subfolder and make the conversion to everything in one go?
Thanks for any advice
Edited by JH12345 - Sept. 1, 2019 04:16:09
-
- Quick Links