目的是扫描给定文件夹中的媒体文件并将 mediainfo 发送到 info.txt 但也为用户提供仅扫描具有特定文本字符串的文件的选项。我的bat文件:
@echo off
setLocal EnableDelayedExpansion
echo. >info.txt
set /P "folder=Enter folder path: "
set /P "_input=Search all files (y/n): "
if /I "%_input%" == "y" (
dir %folder% /B /O:N | findstr /I ".wmv$ .mpg$ .mkv$ .mpeg$ .mp4$ .avi$" >filename.txt
for /f "tokens=* delims= " %%a in ('type filename.txt') do (
set _in=%_in%%%a
mediainfo --Inform=file://template.txt "%folder%!_in!" >>info.txt
echo. >>info.txt
)
) else (
set /P "_str=Enter file string: "
dir %folder% /B /O:N | findstr /I "%_str%" >filename.txt
for /f "tokens=* delims= " %%a in ('type filename.txt') do (
set in=%in%%%a
mediainfo --Inform=file://template.txt "%folder%!in!" >>info.txt
echo. >>info.txt
)
)
del filename.txt
cls
pause
虽然 if 循环的第一部分工作正常,但 'else' 部分没有,但我无法得到错误,因为眨眼间它就消失了,我无法解决它