If you really need the delayed expansion of n1 then your best bet might be to run the loop in a subroutine. Another approach could be processing the output of MORE +!n1! "filename".
Check this out. Just run it, it can't do any harm yet. Then carefully read the comments in order to understand how to customize it. Steffen @echo off REM create both Carriage Return, and the combination of Backspace-Space-Backspace once at the beginning of your code for /f "tokens=1,2 delims=#" %%a ...
ECHO does always write a new line. You need to use the SET /P trick. However, that's not enough. You also need both a Carriage Return character to jump back to the beginning of the line, and the combination of Backspace-Space-Backspace characters to overwrite the previous last character in the line ...
I've been not talking about using something else than XML. I've been talking about using another scripting language to process the XML text. PowerShell, VBScript, JScript for example support the XML DOM to process XML data in a proper way, while Batch does not.
Why oh why are people still trying to accomplish those tasks in batch :( Batch supports line-wise processing of text while XML would be perfectly valid if the whole content was in just one line. Batch is not able to grasp the logical object structure of XML. So what you're doing in Batch is kind of ...
The code below contains two macros. 1) The %ConsoleInfo% macro outputs a sequence of "name=value" pairs which provide information about the console window, such like its appearance, settings, and environment. 2) The %SetConsoleMode% macro updates mode settings of the console window. The mode is an i...
And in this thread I describe a method to load a PowerShell engine just one time and reuse it from a Batch file many times, so the response time is almost the same as an auxiliary .exe file written in assembly language... That's the reason why I asked for the use case. Your technique works marvello...
By default, the %Fade% macro targets the current console window. Optionally, you may pass the process ID of a process whose main window is to be faded. If you target the Windows Terminal, or if you're unsure whether your script spawns a conhost or a Windows Terminal process, pass the PID returned by...
With the Win 11 update KB5019509 last week my expectations came true - Microsoft made Windows Terminal the default terminal app, making the good ol' console window kinda obsolete (it's at least another big step towards it). In the past years I wrote a few PowerShell macros that are related to the co...
Provided the number of tokens separated by an underscore is always 3, and 4 for the sibling: @echo off &setlocal pushd "C:\Data" for /f "delims=" %%i in ('dir /a-d /b "*.pdf"^|findstr /rix "[^_]*_[^_]*_[^_]*\.pdf"') do ( if not exist "%%~ni_*.pdf" echo lone: "%%~i" ) for /f "delims=" %%i in ('dir /a...
Batch 101: Press [Windows]+[R] to open the Run box. Type CMD and hit [Enter] to open a CMD prompt. Type HELP and hit [ENTER] to get an overview of commonly used commands. Type <command> /? (e.g. like ROBOCOPY /? in your specific case) and hit [ENTER] to get detailed information about the command. Th...