python - Am I slicing it right? -




import os import re import nukescripts sys import platform   # f:/projetos/03_o rico e o lazaro/scr_131/cn_04/take_001/setups/nuke/scr_131_cn_04_take_001_comp_v07.nk   s = nuke.selectednode().knob('file').getvalue()  # read node create setup  fullsplit = re.split('/',s)  #turn path list fullsplit = fullsplit[-1]  # hack index last item of list  #split path folder creation split1 = fullsplit.rsplit('_',6)[0] #scenename split2 = re.search(".*(cn_.*)",fullsplit) cn = split2.group(1).rsplit('_',4)[0] #takename split3 = re.search(".*(take_.*)",fullsplit) take = split3.group(1).rsplit('_',2)[0] #scriptname split4 = re.search(".*(scr_.*)",fullsplit) scr = split4.group(1).rsplit('_',6)[0] #novelname split5 = re.search(".*(cbfx_.*)",s) split5 = split5.group(1) novel = re.split('/',split5)[1]  fullscript = scr + '_' + cn + '_' + take + '_comp_v01.nk'  pathname =  server + novel + '/' + scr + '/' + cn + '/' + take + '/setups/nuke/'  filename = pathname + fullscript  try:     #os.makedirs(pathname) except:    pass nuke.scriptsaveas(filename) 

first variable return full path clicking inside software..

s equals

f:/projetos/03_o rico e o lazaro/scr_131/cn_04/take_001/setups/nuke/scr_131_cn_04_take_001_comp_v07.nk

then convert list , index last word -

scr_131_cn_04_take_001_comp_v07.nk

then need split word 3 variables, scr_131, cn_04 , take_001,

that solution had found. there way same results, less lines ofc.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -