Creating a batch script to perform such a task is a bit complex because Windows batch scripting has limited capabilities for media file analysis. To check the video resolution, you would typically need to use a third-party tool like ffmpeg or MediaInfo. These tools can analyze video files and provide detailed information about their properties.
Let's assume you have MediaInfo installed on your system (it's a free and open-source program that you can download from the internet). You can create a batch script that utilizes MediaInfo to check the resolution of video files.
First, download and install MediaInfo CLI (Command Line Interface) from here: https://mediaarea.net/en/MediaInfo/Download/Windows
Here's a sample batch script that would do something similar to what you're asking for. Save the script in a .bat file and place it in the parent directory you wish to scan. Make sure to adjust the mediainfo path in the script if you've installed it in a non-default location:
@echo off
setlocal enabledelayedexpansion
:: Set the path to MediaInfo CLI here
set MEDIAINFO="C:\Path\To\MediaInfo\MediaInfo.exe"
:: Set the directory to scan for video files
set DIRECTORY_TO_SCAN=%~dp0
:: Output file
set OUTPUT_FILE=%DIRECTORY_TO_SCAN%folders_with_low_res_videos.txt
:: Clear the output file
break> "%OUTPUT_FILE%"
:: Supported video file extensions
set VIDEO_EXTENSIONS=*.mp4 *.mkv *.avi *.mov *.flv *.wmv
:: Loop through all subdirectories
for /r "%DIRECTORY_TO_SCAN%" %%D in (.) do (
pushd %%D
for %%F in (%VIDEO_EXTENSIONS%) do (
if exist "%%F" (
for /f "delims=" %%I in ('%MEDIAINFO% --Inform="Video;%%Width%%x%%Height%%" "%%F"') do (
set RESOLUTION=%%I
for /f "tokens=1,2 delims=x" %%A in ("!RESOLUTION!") do (
set WIDTH=%%A
set HEIGHT=%%B
if !WIDTH! lss 1920 if !HEIGHT! lss 1080 (
echo %%D>> "%OUTPUT_FILE%"
goto :nextdir
)
)
)
)
)
:nextdir
popd
)
echo Scan complete. Check '%OUTPUT_FILE%' for folders with videos less than 1080p resolution.
endlocal
pause
Here's what the script does:
- Sets the path to the installed
MediaInfo CLI.
- Defines the directory to scan and the output file location.
- Clears the output file in case it already exists.
- Defines supported video file extensions.
- Loops through all subdirectories and video files, checking their resolution with
MediaInfo.
- If a video file less than 1080p is found, it writes the directory path to the output file.
- Skips to the next directory after finding a match to avoid duplicate entries for the same directory.
Please note that the script uses a simple width x height check assuming that 1080p resolution is 1920x1080. If you want to specifically target other resolutions lower than 1080p, you might need to adjust the comparison logic.
Before running the script, ensure you have the necessary permissions to execute scripts and read the media files in your directories. Also, remember that this script will only list the folder names, without specifying which files are below 1080p.