I have a Windows 10 batch file that runs ffprobe on all files in a directory. Each file name is displayed on the screen on a specific line. When the next file is processed the previous file name is erased and the next file name is written on the same line (so the file names don't run down the screen). I've noticed that for file names greater than 120 characters in length the VT100 escape sequences I'm using break to some extent. Here's the portion of my code that is applicable:
echo Checking files......
for %%a in ("*.*") do (
set filename=%%a
for /f "tokens=1,2,3 delims=," %%a in ('ffprobe [...]') do (
set codec=%%b
)
set /p="%ESC%[1G%ESC%[2K%%~a"<nul
)
set /p="%ESC%[A%ESC%[1G%ESC%[2K"<nul
(I've edited the ffprobe portion just so everything is more readable. ffprobe has nothing to do with the issue I'm seeing).
The escape sequences normally result in the display of the current file name, once ffprobe is finished with that file the cursor is moved to the 1st position on that line and the line (file name) is deleted. After the for loop the line is advanced down so sequence [A is used to move the line back up one so all the files display on the same line.
This has been working fine for months, but I just noticed on a very long file name that was 124 characters the file name is not erased and the next file name is displayed on the following line and the batch file runs correctly from there with that long file name remaining on the screen and the rest of my script runs below it. The way things should work is that each file name is deleted from the screen and none should be shown once this section of the batch file completes.
I deleted characters in the file name to see what number of characters would result in the escape sequences processing correctly and apparently there's a 120 character max.
Is this known behavior? This really isn't a major problem, but it is kind of annoying. Is there anyway to get around this?