Home>

This article gives you a summary of the two methods of using batch processing to obtain the number of txt file lines under the folder and add them to the file name.The ideas are very good,Recommend it to everyone here.

method one:

@echo off & setlocal enabledelayedexpansion
for/f "delims =" %%a in ("dir/a-d/b/s * .txt") do (
  for/f "tokens=3 delims =:" %%b in ("find/c/v" "" %%a "") do set n=%%b
  ren "%%a" "%%~ na_! n:=! %%~ xa"
)
pause

Method Two:

@echo off & setlocal enabledelayedexpansion
%1 (for/f "delims =" %%i in ("%~ 0:^ | sort") do ren %%i)&pause&exit/b
for/f "tokens=1, * delims =" %%i in ("find/c/v" "* .txt") do (
 set info=%%j
 set ln =! info:*:=!
 for/f "delims =" %%a in ("! ln!") do set fn =! info ::%%a =!
 echo;"! fn!" "! fn:~, -4 !! ln:~ 1! .txt"
)

Method for obtaining file line number in batch

@echo off
for/f "tokens=2 delims =:" %%a in ("find/c/v" "data.txt") do set/a result=%%a + 0
echo,%result%
pause

The above methods are actually similar.The execution efficiency is similar,If your friends need it, choose it yourself

  • Previous jQuery to achieve picture carousel special effects code sharing
  • Next Summary of Database Development for JSP Learning