Read the Microsoft support article Command prompt (Cmd. exe) command-line string limitation which explains why not all file names are appended to the environment variable txt
on such a large list of file names.
One workaround solution is writing the file names into a text file and use tools to replace all carriage return + line-feed pairs by a comma.
Here are two solutions using this workaround from answers on
How can you find and replace text in a file using the Windows command-line environment?
@echo off
rem Replace using very fast Xchang32.exe written by Clay Ruth.
dir *.jpg *.jpeg /A-D /B /ON >ImageList1.txt
"%~dp0Xchang32.exe" ImageList1.txt "^x0D^x0A" ",," >nul
rem Replace using a bit slower jrepl.bat written by Dave Benham.
dir *.jpg *.jpeg /A-D /B /ON >ImageList2.txt
call "%~dp0jrepl.bat" "\r\n" "," /M /F ImageList2.txt /O -
Xchang32.exe written by Clay Ruth or jrepl.bat written by Dave Benham must be in same directory as the batch file.
Note 1:
The contents of the image list files end on both solutions with a comma because last line output by DIR also ends with carriage return + line-feed.
I tried also following command line:
call "%~dp0jrepl.bat" "\r\n(?=.)" "," /M /F ImageList2.txt /O -
The regular expression search string \r\n(?=.)
with replace string ,
is working in text editors supporting regular expressions in PRE syntax which would not replace the last carriage return + line-feed in file because the positive lookahead for any character except newline character is not true on last CR+LF, but that is not working with jrepl.bat
using Microsoft's JScript (at least on Windows XP).
Note 2:
On not using *.jpg *.jpeg
on DIR command line it is recommended to create the image list file not in the same directory as DIR is searching for files of any name because in this case the list file would be also included in the list.
Important note: Clay Ruth, author of Xchang32.exe and owner of domain clayruth.com
died years ago. For that reason the ZIP file with this tool is not available anymore in world wide web although it was permitted explicitly to distribute this package free of charge according to read me file in the ZIP file.