Skip to content

Instantly share code, notes, and snippets.

@koloved
Created June 3, 2025 11:21
Show Gist options
  • Save koloved/7bf05a0b44d8dd35410c5fb4fb3bb23d to your computer and use it in GitHub Desktop.
Save koloved/7bf05a0b44d8dd35410c5fb4fb3bb23d to your computer and use it in GitHub Desktop.
bat script for finding JPG and JXL files without corresponding TXT files
@echo off
setlocal enabledelayedexpansion
rem Set the log file name with timestamp
set "logfile=missing_txt_files_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log"
set "logfile=!logfile: =0!"
rem Clear the log file if it exists
if exist "%logfile%" del "%logfile%"
echo Scanning for JPG and JXL files without corresponding TXT files...
echo Starting scan at %date% %time% > "%logfile%"
echo ================================================== >> "%logfile%"
set /a count=0
set /a missing=0
rem Search for JPG files
for /r %%f in (*.jpg) do (
set /a count+=1
rem Check if corresponding TXT file exists (using direct path to avoid delayed expansion)
if not exist "%%~dpnf.txt" (
rem Calculate size in KB
set /a sizeKB=%%~zf/1024
if !sizeKB! equ 0 set /a sizeKB=1
echo Missing TXT: %%f ^(!sizeKB! KB^)
echo %%f ^(!sizeKB! KB^) >> "%logfile%"
set /a missing+=1
)
)
rem Search for JXL files
for /r %%f in (*.jxl) do (
set /a count+=1
rem Check if corresponding TXT file exists (using direct path to avoid delayed expansion)
if not exist "%%~dpnf.txt" (
rem Calculate size in KB
set /a sizeKB=%%~zf/1024
if !sizeKB! equ 0 set /a sizeKB=1
echo Missing TXT: %%f ^(!sizeKB! KB^)
echo %%f ^(!sizeKB! KB^) >> "%logfile%"
set /a missing+=1
)
)
rem Add summary to log file
echo. >> "%logfile%"
echo ================================================== >> "%logfile%"
echo Scan completed at %date% %time% >> "%logfile%"
echo Total JPG/JXL files found: !count! >> "%logfile%"
echo Files missing TXT: !missing! >> "%logfile%"
rem Display summary
echo.
echo Scan completed!
echo Total JPG/JXL files found: !count!
echo Files missing corresponding TXT files: !missing!
echo.
echo Log file saved as: %logfile%
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment