9

ファイルx.dtsxを場所aから場所bにコピーする必要があります。

x.dtsxがすでにbに存在する場合は、x.dtsxの名前をx_Standby.dtsxに変更する必要があります。次に、名前を変更した後、x.dtsxをbにコピーします。

私の現在のコードは次のようになります。

if exists %1 rename %1 %(should be 1_standy.extension)
xcopy %1 %2
4

1 に答える 1

35

Command Processor Extensions (Windows 2000 以降のデフォルト) を使用する場合は、次のオプションの構文を使用できます。

%~1         - expands %1 removing any surrounding quotes (")
%~f1        - expands %1 to a fully qualified path name
%~d1        - expands %1 to a drive letter only
%~p1        - expands %1 to a path only
%~n1        - expands %1 to a file name only
%~x1        - expands %1 to a file extension only
%~s1        - expanded path contains short names only
%~a1        - expands %1 to file attributes
%~t1        - expands %1 to date/time of file
%~z1        - expands %1 to size of file

修飾子を組み合わせて、複合結果を得ることができます。

%~dp1       - expands %1 to a drive letter and path only
%~nx1       - expands %1 to a file name and extension only

したがって、コマンドは次のようになります。

if exist %2\%~nx1 ren %2\%~nx1 %~n1_standby%~x1
于 2012-01-05T21:13:13.247 に答える