saca Posted April 15, 2021 Share Posted April 15, 2021 hi, very basic question i have, I want get most newest version file for "Load_Layer(LOP):File parameter" example in python import glob import re import os max(glob.glob('C:/USD/myUSD_v*.usda')) return>'C:/USD/myUSD_v003.usda' this code running in python, but not running in Houdini. this code does not include Houdini objects. how to write the code in this case? thanks Quote Link to comment Share on other sites More sharing options...
saca Posted April 16, 2021 Author Share Posted April 16, 2021 resolved 0)files example > 'C:/myGeo/myGeo_v001.begeo.sc','C:/myGeo/myGeo_v002.begeo.sc' 1)set default Language = Python 2)Ctrl+E fot multi line script on the parameter slot import os thePath = 'C:/myGeo/' fileList = os.listdir(thePath) return thePath + max(fileList) return 'C:/myGeo/myGeo_v002.begeo.sc' thanks Quote Link to comment Share on other sites More sharing options...
saca Posted April 16, 2021 Author Share Posted April 16, 2021 (edited) Better way, ignore folders , files only "isfile" import os thePath = 'C:/myGeo/' fileList = os.listdir(thePath) isFileList = [] for f in fileList: if os.path.isfile(os.path.join(thePath, f)): isFileList.append(f) fName = (thePath + max(isFileList)) #print fName return fName Edited April 16, 2021 by saca 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.