This is going to sound strange, but after switching to Windows 11, I found that the behavior of a batch .cmd file FOR loop has radically changed.
I'm working on MP4 file processing. During processing I do the following.
- Rename the the file from example.mp4 to example.mp4_original
- Use example.mp4_original to re-create example.mp4 with updated metadata
- do some additional stuff to example.mp4
I use this simple FOR loop to find and process all MP4 files in the directory:
for %%A in (.\*.mp4) do (
call :processing "%%~nxA"
)
Pre-Windows 11 this worked perfectly fine. The FOR loop would find each MP4 file in the directory, I would do the processing, and when I was done, my directory would look like this:
example1.mp4_original
example1.mp4
example2.mp4_original
example2.mp4
example3.mp4_original
example3.mp4
But with Windows 11, the FOR loop behavior has changed. It sounds weird, but his is what it is doing. If I just loop and print out filenames, I'll get a list of all MP4 files:
example1.mp4
example2.mp4
example3.mp4
However, when I do my processing and rename example1.mp4 to example1.mp4_original and then recreate example1.mp4, what the FOR loop in Windows 11 is now doing is somehow "finding" the new example1.mp4 and "adds" it to the FOR loop so effectively the FOR loop now loops forever reprocessing the files over and over again.
Now I thought there might be something wrong with my processing so I created a simple example that all it did was rename example1.mp4 to example1.mp4_original and then used the copy command to copy example1.mp4_original as example1.mp4. Sure enough, the FOR loop again somehow "finds" this new file and "adds" it to the FOR loop.
I have never seen behavior like this before. Anyone have any thoughts?