- @echo off
- set str=今日明月在
- set var=%str:~0,3%
- type nul>f:\1.txt
- echo %str:~0,2%>f:\1.txt&&type f:\1.txt
- pause
- @echo off
- ::不好意思把字符分开截取FOR
- set str=今日,明月,在
- type nul>f:\2.txt
- set var=%str:~-4%
- echo %str:~-4%
- echo %str:~-4%>f:\2.txt&&type f:\2.txt
- echo var=2.txt
- if exist f:\2.txt (echo F盘下有2.txt存在) else (echo f盘下没有2.txt存在)
- for /f %%i in (f:\2.txt) do echo %%i
- for /f "delims=," %%i in (f:\2.txt) do echo %%i
- pause
- @echo off
- set str=明月,在
- set var=%str:~0,2%
- echo %str:~0,2%
- type nul>f:\3.txt
- echo %str:~0,2%>f:\3.txt&&type f:\3.txt
- @echo off
- set str=明月,在
- set var=%str:-1%
- echo %str:~-1%
- type nul>f:\4.txt
- echo %str:~-1%>f:\4.txt&&type f:\4.txt
- pause
- @echo off
- type f:\1.txt>>f:\3.txt
- type f:\4.txt>>f:\3.txt
- type f:\3.txt
- pause
复制代码 [attach]7375[/attach]复制代码 |