//# //#

2015/07/20

【Max】MaxScriptメモ(その1)ファイル、パス周り

色々な言語が混じってよく分からなくなってきたのでメモ代わりに
ファイル、パスに関するコマンドをいくつか。


fileDir = maxFilePath --シーンファイルのディレクトリ取得
fileName = maxFileName --拡張子付きのファイル名取得
fileFullpath = fileDir + fileName --シーンファイルのフルパス取得
dirArray = filterString fileFullPath @"\" --パスを¥区切りで配列に変換


testFullPath = @"Z:\hoge\fuga.ext" --sample

getFilenamePath testFullPath --stringのディレクトリのみ取得
--//"Z:\hoge\"//
filenameFromPath testFullPath --stringのファイル名と拡張子を取得
--//"fuga.ext"//
getFilenameFile testFullPath --stringのファイル名のみ取得
--//"fuga"//
getFilenameType testFullPath --stringの拡張子のみ取得
--//".ext"//
doesFileExist testFullPath --ファイルの有無の確認


oRootPath = @"Z:\hoge\"
getDirectories (oRootPath + "*") --変数ディレクトリ以下のディレクトリ全てを配列で返す。
getFiles (oRootPath + "*") --変数ディレクトリ以下のファイル全てを配列で返す。


tempDir = oRootPath + @"_old"
makeDir tempDir --ディレクトリの作成
tempFile = filenameFromPath testFullPath
renameFile testFullPath (tempDir + @"\" +  tempFile) --ファイルの移動(パスのリネーム)


str = "move  " + oRootPath+ "aaa" +  " _old\\aaa" --Dosコマンド(ディレクトリをサブディレクトリ、ファイルごと移動)
hiddendoscommand str startpath:oRootPath exitCode:&exitcode --Dosを実行、実行場所をstartpathで指定、exitcodeでエラーを確認
exitcode --成功した場合0を返す。


-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+