Wait for you all experts to solve it, and then I'll learn slowly. I'm too bad at CMD batch processing, just started learning.
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Originally posted by lxmxn at 2006-12-12 00:50:
There is another problem. If there are blank lines (just pressing Enter) in a.txt, then an error will occur, and the batch file prompts:
The maximum setlocal recursion level has been reached.
I don't know how to solve this problem?
@echo off
set num=0
for /f "delims=" %%i in ('findstr /n .* test.txt') do (
set /a num+=1
set "str=%%i"
setlocal enabledelayedexpansion
echo Line !num!: !str:*:=!
endlocal
)
pause
@echo off
(for /f "delims=" %%i in ('more ^< "%~f1" ^| findstr /n .*') do (
set "str=%%i"
setlocal enabledelayedexpansion
echo;!str:*:=!
endlocal
))>test.out
fc "%~f1" test.out
pause
@echo off
if "%1"=="" %0 "%~f0"
(for /f "delims=" %%i in ('more ^< %1 ^| findstr /n .*') do (
set "str=%%i"
setlocal enabledelayedexpansion
echo;!str:*:=!
endlocal
))>test.tmp
type test.tmp
echo ---------
more < %1 > %1.tmp
fc %1.tmp test.tmp
pause
hxuan?表ー: 2006-12-13 18:28
- @echo off
- if "%~1"=="" (
- %0 "%~f0"
- goto :eof
- )
- (for /f "usebackq delims=" %%i in (`more ^< %1 ^| findstr /n .*`) do (
- set "str=%%i"
- setlocal enabledelayedexpansion
- echo;!str:*:=!
- endlocal
- ))>"%~dp1test.tmp"
- type "%~dp1test.tmp"
- echo ------------------
- more < "%~1" > "%~1.tmp"
- fc "%~1.tmp" "%~dp1test.tmp"
- pause
@echo off
setlocal disabledelayedexpansion
set num=0
for /f "delims=" %%i in ('findstr /n .* test.txt') do (
set /a num+=1
set "str=%%i"
setlocal enabledelayedexpansion
echo Line !num!: !str:*:=!
endlocal
)
pause