Home > OS >  For batch orders
For batch orders

Time:10-14

I want to write a bat script
Requirements are as follows:
Execute the script will take the all js files in the directory path listed, but if the file contains the indication min, or file only one line of js files don't
The scripts I wrote a little, the rest can't write the
 

@ echo off
A CD for/r % % % % in (*. Js) do (

Echo % % a | findstr searches "min" & gt; Nul
If % % errorlevel equ (1
Echo % % a
) else (
Echo "notok"
)
)
Pause> Nul& The exit



The script is effective only the traversal folder
When matching min keyword effect always not
, another judge file number nor write lines
Pray god to guide

CodePudding user response:

Matching min keywords to change like this:
@ echo off
Setlocal enabledelayedexpansion
A CD for/r % % % % in (*. Js) do (

Echo % % a | findstr searches "min" & gt; Nul
if ! Errorlevel! The equ (1
Echo % % a
) else (
Echo "notok"
)
)
Pause> Nul& exit

CodePudding user response:

This can achieve your requirements:
@ echo off
Setlocal enabledelayedexpansion
A CD for/r % % % % in (*. Js) do (
Echo % % a | findstr searches "min" & gt; Nul
if ! Errorlevel! The equ (1
The set sub_a=% % a
The set multiline="0"
Call: sub
if ! Multiline!=="1" echo % % a
)
)
Pause> Nul& The exit

: sub
For/f "usebackq skip=1" % % b (sub_a "% %") in the do (
The set multiline="1"
Goto: eof
)
Goto: eof
  • Related