Home > other >  Questions about DOS batch cycle
Questions about DOS batch cycle

Time:09-16

The following is a batch program, this is to want to compare two files exist audio files are consistent, inconsistent and replace, used for debugging now 2. TXT file content is dir in the current directory content, but the outer loop executed only once, 2. TXT of dozens of lines, read only the first not to perform, this code I've changed back and forth many times, as long as the goto jump in the middle are removed, execution is no problem, consult everybody, why outer loop executed only once, what was wrong with the code?

Dir item read below are respectively, byte file modification date time four

@ echo off
Setlocal enabledelayedexpansion
The set/a js=0
The set/a what zj had=0

For/F "tokens=1-3, *" % % I in (2. TXT) do (

The set filename1=% % l
The echo! Filename1!
The set byte1=% % k
The set dd1=% % I
The set hh1=% % j
Set the DR=dir! "" Filename1!"
The set/a what zj had=! What zj had! + 1

For/F "skip=5 tokens=1-3, *" % % a in ('! DR! ') do (

Set the filename=% % d
The set byte=% % c
Set the dd=% % a
The set hh=% % b

If "! Filename1!"=="! The filename!" (
If not "! Byte1!"=="! Byte!" Goto byte_neq
If not "! Dd1!"=="! Dd!" Goto date_neq
If not "! Hh1!"=="! Hh!" Goto time_neq
Goto next
: byte_neq
The set/a js=! Js! + 1
The echo! Filename1! - -! Byte1! - -! Byte! Range - byte
: date_neq
The set/a js=! Js! + 1
The echo! Filename1! - -! Dd1! - -! Dd! - date range
: time_neq
The set/a js=! Js! + 1
The echo! Filename1! - -! Hh1! - -! Hh!!! - time and tide wait for no
: next
The set filename1=

)
)

)
if ! Js! The equ (0
Echo in total! What zj had! A file, all files are consistent
) else (
Echo in total! What zj had! A file, there is! Js! A file is not consistent
)
  • Related