本帖最后由 CrLf 于 2014-11-26 22:59 编辑
回复 18# amwfjhh
这样可以兼容文件名含 ! 的情况,做个对比实验就懂了:- @echo off
- (for /f "delims=" %%a in (%~s0) do (
- set str=%%a
- setlocal enabledelayedexpansion
- echo !str!
- endlocal
- ))>test1.txt
- pause
复制代码
- @echo off&setlocal enabledelayedexpansion
- (for /f "delims=" %%a in (%~s0) do (
- set str=%%a
- echo !str!
- ))>test2.txt
- pause
复制代码
|