在此代码中它将pcap文件转换为csv,但我想添加大小条件
为了转换大于或等于1兆字节的pacp文件
这是代码
:START
set /a Old = 0
set /a New = 0
echo Counting files in folder..
for /f "tokens=*" %%P IN ('dir "C:\Users\..." /A /b') do (set /a Old += 1)
set Old
:: delay 120 sec
echo Delaying 120 seconds... (drop new file in)
timeout /T 9
echo Checking for new files..
for /f "tokens=*" %%P IN ('dir "C:\Users\S..." /A /b') do (set /a New += 1)
set New
goto COMPARE
:COMPARE
echo Comparing number of files
if %New% GEQ %Old% goto NEWF
goto OLDF
:NEWF
echo
**for %%F in (*.pcap) do if not exist "%%~dpnF.csv" tshark -r "%%F" -T fields -E header=y -E separator=, -E quote=d -e frame.number -e frame.time -e ip.src -e ip.dst -e data.text -e tcp.analysis.duplicate_ack -e tcp.analysis.out_of_order -e tcp.analysis.retransmission -e tcp.analysis.fast_retransmission -e tcp.analysis.spurious_retransmission -e tcp.analysis.zero_window -e tcp.stream -e tcp.srcport -e tcp.dstport -e data.len > "%%~dpnF.csv"**
goto START
:OLDF
echo No New Files.
echo Restarting
goto START
我想在NEWF
之后在echo中添加for循环条件任何帮助谢谢
答案 0 :(得分:0)
for %%F in (*.pcap) do IF %%~zF GTR 1048576 if not exist "%%~dpnF.csv" tshark -r "%%F" -T fields -E header=y -E separator=, -E quote=d -e frame.number -e frame.time -e ip.src -e ip.dst -e data.text -e tcp.analysis.duplicate_ack -e tcp.analysis.out_of_order -e tcp.analysis.retransmission -e tcp.analysis.fast_retransmission -e tcp.analysis.spurious_retransmission -e tcp.analysis.zero_window -e tcp.stream -e tcp.srcport -e tcp.dstport -e data.len > "%%~dpnF.csv"**
仅当%%F
中文件的大小大于1Mb时,才应执行该行的其余部分