Windows CMD substr

user-pic
Vote 0 Votes

這個技巧是用在 Windows CMD 批次檔中切字串使用, 純 DOS 環境不適用

C:\>echo %windir%
C:\Windows

從第一個字的位置(0)開始取2碼
C:\>echo %windir:~0,2%
C:

從第3位置開始取4碼
C:\>echo %windir:~3,4%
Wind

從第3位置開始取到結尾
C:\>echo %windir:~3%
Windows

Leave a comment

About this Entry

This page contains a single entry by Pank published on October 21, 2011 10:38 PM.

泰國水災造成硬碟漲價 was the previous entry in this blog.

Bid and Buy is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives