Mayamanで作成したribを別の場所に移す

Mayamanから吐き出されたribとbatは、フルパスが書き込まれているため、
ファイルの移動はかなり骨が折れます。

以下のスクリプトは、rib,bat,search_pathの時はファイルの中のパスを
コピー先のパスに置き換えます。

具体的には、ローカル作業してたんだけど
レンダリングのためにサーバに上げたい時とかですね。

import os import os.path import shutil import string #currentProject LOCAL_DIR = 'C:/localProject/mayaman/ribs/sceneA' LOCAL_RIB = os.path.dirname(LOCAL_DIR) LOCAL_MM = os.path.dirname(LOCAL_RIB) LOCAL_PRJ = os.path.dirname(LOCAL_MM) LOCAL_PRJ_WINPATH = string.replace(LOCAL_PRJ, '/', '\\') #Mayamandir in Server SRV_MM = 'Z:/MayaProject/mayaman' SRV_PRJ = os.path.dirname(SRV_MM) SRV_PRJ_WINPATH = string.replace(SRV_PRJ, '/', '\\') def replacePath(oldfilepath, newfilepath): #if distination exists, remove it. if os.path.isfile(newfilepath): os.remove(newfilepath) #if there is no directory, make it if not os.path.isdir(os.path.dirname(newfilepath)): os.makedirs(os.path.dirname(newfilepath),077) f = open(oldfilepath,'r') o = open(newfilepath,'a+') for line in f: o.write(line.replace(LOCAL_PRJ_WINPATH, SRV_PRJ_WINPATH)) f.close() o.close() #re-write all bats and ribs. def ex_change(localDir, mayamanPath): parentDir = os.path.basename(localDir) totalNum = 0 for root, dirs, files in os.walk(localDir): for file_ in files: totalNum += 1 currentNum = 0 for root, dirs, files in os.walk(localDir): for file_ in files: print '(' + str(currentNum) + '/' + str(totalNum) + ')', oldfilename = file_ oldfilepath = os.path.join(root, oldfilename) newfilepath = mayamanPath + '/ribs/'+ parentDir + oldfilepath[len(localDir):] newfilepath = os.path.abspath(newfilepath) #edit if newfilepath[-4:]=='.rib' or newfilepath[-4:]=='.bat' or newfilepath[-12:]=='.search_path': replacePath(oldfilepath, newfilepath) else: #just copy if not os.path.isdir(os.path.dirname(newfilepath)): os.makedirs(os.path.dirname(newfilepath),077) shutil.copy(oldfilepath, newfilepath) print newfilepath currentNum += 1 ex_change(LOCAL_DIR, SRV_MM)
注意点
  • tex_cacheフォルダについては手でやってください。
  • レンダリング先のディレクトリが無いとレンダリング落ちると思います。
最終更新:2008年05月20日 17:27
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。