Monday, March 28, 2011

DOS Command Line Batch File 문법

%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.

%CmdCmdLine% will return the entire command line as passed to CMD.EXE
%* will return the remainder of the command line starting at the first command line argument (in Windows NT 4, %* also includes all leading spaces)
%~dn will return the drive letter of %n (n can range from 0 to 9) if %n is a valid path or file name (no UNC)
%~pn will return the directory of %n if %n is a valid path or file name (no UNC)
%~nn will return the file name only of %n if %n is a valid file name
%~xn will return the file extension only of %n if %n is a valid file name
%~fn will return the fully qualified path of %n if %n is a valid file name or directory

예제 : Gnomonology Rendering Zbrush Displacement Maps 를 만든 Scott Spenser 의 배치 파일

:convertfile
@IF %1 == "" GOTO end
imf_copy -p %1 "%~d1%~p1%~n1.map"
@SHIFT
@GOTO convertfile
:end
@ECHO.
@ECHO Done!
@pause

출처 : http://www.robvanderwoude.com/parameters.php
키워드 : Command line parameters
미러 : Dos Batch File Parameters

No comments:

Post a Comment