Jump to content

get most newest version file


saca

Recommended Posts

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

2021-04-15_16h40_38.png

Link to comment
Share on other sites

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

 

2021-04-16_17h36_09.png

Link to comment
Share on other sites

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 by saca
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...