Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whaison/4d4ad63ee0eb2cf84701726c084aeed2 to your computer and use it in GitHub Desktop.
Save whaison/4d4ad63ee0eb2cf84701726c084aeed2 to your computer and use it in GitHub Desktop.
mayabatch_Xcopy_RefImport_OneTimeline_Simple.bat
::"C:\Program Files\Autodesk\Maya2017\bin\mayapy.exe" "C:\temp\hello.py"
::"C:\Program Files\Autodesk\Maya2016\bin\mayapy.exe" -c "import sys;print sys.argv" test 1234 %date%
::['-c', 'test', '1234', '2016/11/08']
:: Dドライブへ移動する
cd /d d:
:: batファイルで、そのファイル自身のパスを取得するしそのディレクトリをカレントディレクトリに。
cd /d %~dp0
::【cmd】カレントディレクトリの「フォルダ名」を取得する
:: echo onになっていると、結果だけでなく実行されるコマンド文字列がそのまま表示されます
::@echo off
@echo on
:: 実行中に値を変化させたい場合
setlocal ENABLEDELAYEDEXPANSION
::------------------------------------------------------
set BatchFileDirPath=%~dp0
echo %BatchFileDirPath%
::バッチファイル内で、カレントディレクトリのフルパスではなく自分のいるディレクトリ名(フォルダ名)だけを取得http://fpcu.on.coocan.jp/dosvcmd/bbs/log/dir/3-0481.html
for %%I in (.) do set DIRNAME=%%~nI%%~xI
echo %DIRNAME%
::cd ../
cd /d ../
echo %DIRNAME%
set CopyDirName=%DIRNAME%
echo %CopyDirName%
set PastDir=_auto
echo %PastDir%
set ParentDir=%CD%
echo %ParentDir%
set CopyPath=%ParentDir%\%CopyDirName%
echo %CopyPath%
set PastPath=%ParentDir%\%CopyDirName%%PastDir%
echo %PastPath%
::cd %CopyPath%
xcopy %CopyPath% %PastPath% /D /S /Y /I
::コピー先をカレントに
cd /d %PastPath%
set MayaWorkspace=%CD%
echo %MayaWorkspace%
set EscapedMayaWorkspace=%MayaWorkspace%
:: 置換
set old=:\
set new=////
call set EscapedMayaWorkspace=%%EscapedMayaWorkspace:%old%=%new%%%
set old=\
set new=/
call set EscapedMayaWorkspace=%%EscapedMayaWorkspace:%old%=%new%%%
echo %EscapedMayaWorkspace%
cd /d c:
set MayaExeBinPath=C:\Program Files\Autodesk\Maya2016\bin\
cd /d %MayaExeBinPath%
set PythonCode=import maya.cmds as cmd;
set PythonCode=%PythonCode%import python.MotionMerge.p015Reference_importReference.Mayabatch_refImport_And_oneTimeLine_Chara as Mayabatch_refImport_And_oneTimeLine_Chara;
set PythonCode=%PythonCode%Mayabatch_refImport_And_oneTimeLine_Chara.Mayabatch_refImport_And_oneTimeLine_Chara('%EscapedMayaWorkspace%');
set PythonCode=%PythonCode%print('mayabatchExeCommandEnd')
mayabatch.exe -command "python(\"%PythonCode%\")"
::閉じない
cmd /k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment