Part of what I want to do is go through the list of files in a directory and show those file names on one line (not consecutive lines flowing down the screen) to show the user that they are being processed. I also don't mean file names written one after the other across the screen. I mean, for example, everything stays on the top line, starts writing from the far left and never moves down the screen. Each file name occupies the spot where the previous file name was output. I started out using the following to do that:
Code: Select all
for %%a in ("*.*") do set filename=%%a
for /f %%h in ('copy "%~f0" nul /z') do set "CR=%%h"
set /p ".=!filename! !CR!" < nul
short.txtame.txt
since the 9 charters in the file name short.txt overwrite only the first 9 characters of the file name longfilename.txt. I don't know if this is because of changes made to batch file behavior in Windows 10, but I suspect this to be the case.
I posted this question on reddit and someone suggested the following code using VT100 escape sequences:
Code: Select all
ECHO OFF
FOR /F %%A in ('ECHO prompt $E^| cmd') DO SET "ESC=%%A”
FOR %%E in (“longfilename.txt” “short.txt” “mediumfile.txt”) DO (
ECHO %ESC%[1G%ESC%[2K%%~E
PAUSE>NUL
)
1G2KΓÇ£longfilename.txtΓÇ¥
1G2KΓÇ£short.txtΓÇ¥
1G2KΓÇ£mediumfile.txtΓÇ¥
I suspect there's something I need to have set in order for these codes to work, possibly in the registry, that isn't actually set. I've Googled this issue and found a note on Stack Overflow that says that I can test if VT100 sequences are enabled by issuing this to Powershell: "?[1;31mele ?[32mct ?[33mroni ?[35mX ?[36mtar ?[m".Replace('?', [char]27);
That line does output properly assigning colors to: "ele ct roni X tar" as intended, however I was worried that making changes to the registry that they suggested only applied to Powershell and not the cmd window.
But, as I describe above this stuff isn't working in the plain old cmd window. I am not an expert in batch writing and manage to get most things to work only by Googling them and finding where someone else has tried to do what I want to do so PLEASE don't suggest I try to do this in a Powershell script or C. I know a few languages, but those two aren't part of my repertoire. This is just a pet project of mine.