Mid*_*tro 3 windows drag-and-drop batch-file tshark
我试图通过运行批处理文件来处理多个文件。我希望该批处理文件能够接收其给定的所有文件(又名转储;或拖放)并处理它们。
目前,我可以使用以下批处理命令单独处理文件:
"C:\Program Files\Wireshark\tshark.exe" -r %1 -Y "filter" -o "uat:user_dlts:\"User 8 (DLT=155)\",\"pxt\",\"0\",\"\",\"0\",\"\"" -o "gui.column.format:\"Info\",\"%%i\""> %1".filter.txt"
Run Code Online (Sandbox Code Playgroud)
我希望做与上述相同的事情,但是能够将文件简单地拖放到要处理的批处理文件中。
对于那些对上述批处理文件感到困惑的人:
-r读取输入文件,其完整文件地址(包括扩展名)被%1捕获
-Y过滤掉拖放文件的某些部分
-o设置首选项(由运行可执行文件的“ s”:tshark.exe-
>将结果重定向到
stdout-%1“ .filter.txt”将结果输出到名为“ draggedfilename.filter.txt”的新文件中
请避免在其他任何地方使用此代码,但要帮助我使用此代码(由于使用该代码的应用程序)。为了隐私起见,我在此版本的代码中更改了几个标志。如果您有任何疑问,请告诉我!
使用%*代替%1。
范例:
@echo off
for %%a in (%*) do (
"C:\Program Files\Wireshark\tshark.exe" -r "%%a" -Y "filter" -o "uat:user_dlts:\"User 8 (DLT=155)\",\"pxt\",\"0\",\"\",\"0\",\"\"" -o "gui.column.format:\"Info\",\"%%i\""> "%%a"".filter.txt"
)
Run Code Online (Sandbox Code Playgroud)
用%%i正确的变量替换。
您可以使用goto和shift这样进行循环(rem有关详细信息,请参见注释):
:LOOP
rem check first argument whether it is empty and quit loop in case;
rem `%1` is the argument as is; `%~1` removes surrounding quotes;
rem `"%~1"` therefore ensures that the argument is always enclosed within quotes:
if "%~1"=="" goto :END
rem the argument is passed over to the command to execute (`"%~1"`):
"C:\Program Files\Wireshark\tshark.exe" -r "%~1" -Y "filter" -o "uat:user_dlts:\"User 8 (DLT=155)\",\"pxt\",\"0\",\"\",\"0\",\"\"" -o "gui.column.format:\"Info\",\"%%i\""> "%~1.filter.txt"
rem `shift` makes the second argument (`%2`) to be the first (`%1`), the third (`%3`) to be the second (`%2`),...:
shift
rem go back to top:
goto :LOOP
:END
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6480 次 |
| 最近记录: |