多个pcap文件到CSV文件

时间:2019-02-11 05:43:16

标签: csv batch-file pcap

我有一个包含数千个pcap文件的文件夹,我想将每个pcap文件转换为一个csv文件

示例:

<button type="button" onclick="logout('<?php echo $SESSION['user']['userId'] ?> ')" class="btn-danger">logout</button>
function logout(id) {
    swal({
        title: "Do you want to logout this Account?",
        type: "error",
        showCancelButton: true,
        confirmButtonClass: "btn-danger",
        confirmButtonText: "Yes!",
        cancelButtonText: "No",
        closeOnConfirm: true,
        closeOnCancel: true
    },
            function (isConfirm) {
                if (isConfirm) {
                    userLogout(id);
                }
            });
}

function userLogout(id) {
    $.post(base_url + "fileName/method_name", {id: id}, function (data) {
        if (data === "1") {
            }
         else if (data === "0") {
            swal("", "Error to logout user.", "warning");
        } else {
            swal("", data[0], "error");
        }
    });
}

.bat文件:

convert 1.pcap to 1.csv
convert 2.pcap to 2.csv
convert 3.pcap to 3.csv

没有输出,输出是: The output

1 个答案:

答案 0 :(得分:0)

很遗憾,由于我没有可执行文件,因此我无法测试,但是如果您要将每个.cap文件转换为自己的.csv,那么应该可以执行以下操作:

@echo off 
set "cap_folder=D:\testfolder\"
Cd /d "%cap_folder%"
set "tshark_cmd=c:\Program Files\Wireshark\tshark"
set "tshark_options=-n -T fields -e frame.number -e frame.time -e ip.src -e ip.dst -e ip.proto -e frame.len -E header=y -E separator=, -E quote=d -E occurrence=f"

for /f "delims=" %%i in ('dir /b /a-d "*.cap"') do (
   echo Processing File: %%i
   "%tshark_cmd%" -r %%i %tshark_options% >>%cap_folder%\%%~ni.csv
)