{"id":461,"date":"2010-12-25T11:08:00","date_gmt":"2010-12-25T11:08:00","guid":{"rendered":"http:\/\/www.kurianos.com\/wordpress\/?p=461"},"modified":"2010-12-25T11:08:00","modified_gmt":"2010-12-25T11:08:00","slug":"sequence-rename","status":"publish","type":"post","link":"https:\/\/www.kurianos.com\/wordpress\/?p=461","title":{"rendered":"Sequence Rename"},"content":{"rendered":"<p>small python Sequence Rename<br \/>\n[Python]<br \/>\nimport os<br \/>\nimport re<br \/>\ndef readSequence(seqDir):<\/p>\n<p>  getAllfileList = os.listdir(seqDir)<br \/>\n  for eachFile in getAllfileList:<br \/>\n    reExp = re.compile(&#8216;[0-9]+&#8217;)<br \/>\n    #print os.path.splitext(eachFile)<br \/>\n    getFileNumcnt = reExp.search(eachFile).group()<br \/>\n    newIntValue = &#8216;%04d&#8217;%int(getFileNumcnt)<br \/>\n    newFileName = &#8216;%s\/%s.%s%s&#8217;%(seqDir,os.path.splitext(eachFile)[0].split(&#8216;_&#8217;)[0],newIntValue,os.path.splitext(eachFile)[-1])<br \/>\n    oldFileName = &#8216;%s\/%s&#8217;%(seqDir,eachFile)<br \/>\n    print oldFileName,newFileName<br \/>\n    os.rename(oldFileName,newFileName)<br \/>\nreadSequence(&#8216;\/home\/******\/***\/hrender&#8217;)<br \/>\n[\/Python]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>small python Sequence Rename [Python] import os import re def readSequence(seqDir): getAllfileList = os.listdir(seqDir) for eachFile in getAllfileList: reExp = re.compile(&#8216;[0-9]+&#8217;) #print os.path.splitext(eachFile) getFileNumcnt = reExp.search(eachFile).group() newIntValue = &#8216;%04d&#8217;%int(getFileNumcnt) newFileName = &#8216;%s\/%s.%s%s&#8217;%(seqDir,os.path.splitext(eachFile)[0].split(&#8216;_&#8217;)[0],newIntValue,os.path.splitext(eachFile)[-1]) oldFileName = &#8216;%s\/%s&#8217;%(seqDir,eachFile) print oldFileName,newFileName os.rename(oldFileName,newFileName) readSequence(&#8216;\/home\/******\/***\/hrender&#8217;) [\/Python]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[15,14],"tags":[],"class_list":["post-461","post","type-post","status-publish","format-standard","hentry","category-linux","category-python"],"_links":{"self":[{"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=461"}],"version-history":[{"count":1,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/461\/revisions"}],"predecessor-version":[{"id":462,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/461\/revisions\/462"}],"wp:attachment":[{"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kurianos.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}