2012-04-18 17 views
0

BATファイルで ':〜'記号がかなり頻繁に使用されているのを見て、それはある位置に文字があると推測しますが、これの確認や方法/時期それを使用する(それはまた範囲を得ることができるようである)。BAT:〜文字列の構文

これについていくつかの光を放つことができれば、ありがとう。

SET STRING=C:\MyDocuments\ 
IF "%STRING:~-1%"=="\" SET STRING=%STRING:~0,-1% 
ECHO String: %STRING% 

%% A:〜-1も有効ですか?またはそれを ""で囲む必要がありますか?コマンドラインでの

答えて

1

タイプ

help set 

、あなたは完全な説明を取得します。いくつかは、forコマンドの助けを借りて文書化されています。したがって、help forはあなたに追加情報を提供します。

これは、「ヘルプセット」コマンドの出力の一部です:

May also specify substrings for an expansion. 

    %PATH:~10,5% 

would expand the PATH environment variable, and then use only the 5 
characters that begin at the 11th (offset 10) character of the expanded 
result. If the length is not specified, then it defaults to the 
remainder of the variable value. If either number (offset or length) is 
negative, then the number used is the length of the environment variable 
value added to the offset or length specified. 

    %PATH:~-10% 

would extract the last 10 characters of the PATH variable. 

    %PATH:~0,-2% 

would extract all but the last 2 characters of the PATH variable. 
+0

はあなたに感謝します!あまりにもhahaのヘルプコマンドを忘れてしまった – user1229895