Search found 1042 matches
- 08 Apr 2024 01:33
- Forum: DOS Batch Forum
- Topic: How to dynamically escape % symbols?
- Replies: 4
- Views: 572
Re: How to dynamically escape % symbols?
We have automation passwords that need to be encrypted for our financial applications. We have a password generator/randomizer that we use. When % symbols are present, we need to remember to always escape them, however, a lot of the folks forget to do that. Without further description of the involv...
- 18 Feb 2024 03:06
- Forum: DOS Batch Forum
- Topic: Automating the generation of macros usable within other macros
- Replies: 4
- Views: 2811
Re: Automating the generation of macros usable within other macros
Hi jfl, One side issue I'm still investigating is a good way to define a %%variable that generates a %. Using a %%p variable is easy, but this might interfere with a user-defined %%p variable. I tried using the same syntax with a caret, as for the other tricky characters: for %%^% in (1 2) do ... Th...
- 12 Feb 2024 10:29
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 10578
Re: Macro for Dummies
@jfl Nice efforts :D Note that with expansion enabled, and in the absence of a ! in the command, both the FOR! and FOR!! macros generate two ^^ for each %%^^. This is unavoidable. But the solution for this problem should be obvious 8) From the Batch Library/libBase.cmd REM *** Creating %%! and %%^ f...
- 11 Feb 2024 15:11
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 10578
Re: Macro for Dummies
because the behavior differs marginally. ultimately though, ts a preference to convery the purpose Your example only shows the fact that a variable can be expanded, when the name is complete @echo off Set a1 =-ONE- Set "a1 ^=-TWO-" Setlocal EnableDelayedExpansion for /f %%! in ("!a1 ! ^^^!") Do Ech...
- 22 Jan 2024 03:29
- Forum: DOS Batch Forum
- Topic: 3D Cube Orthographic Projection
- Replies: 3
- Views: 4341
Re: 3D Cube Orthographic Projection
Hi IcarusLives, nice picture, but currently the code on my WIN10 only produces: Fehlender Operand Fehlender Operand Fehlender Operand [2J[38;5;1m[0;1H´┐¢[0m[38;5;6m[0;1H´┐¢[0m[38;5;11m[0;1H´┐¢[0m[38;5;2m[0;1H´┐¢[0m[38;5;7m[0 ;1H´┐¢[0m[38;5;12m[0;1H´┐¢[0m[38;5;3m[0;1H´┐¢[0m[38;5;8m[0;1H´┐¢[0m[38;5;13...
- 19 Jan 2024 07:09
- Forum: DOS Batch Forum
- Topic: Faster batch macros
- Replies: 17
- Views: 11393
Re: Faster batch macros
Uhh that's something that can drive you mad. You need to glue it to the next command because it would be treated as a separate command otherwise. Even an empty string or a space is parsed like that. I can't make my brain remember the order and details of script parsing. The parser splits in phase 2...
- 19 Jan 2024 06:57
- Forum: DOS Batch Forum
- Topic: NOP+nested code.
- Replies: 25
- Views: 22991
Re: NOP+nested code.
I build a test script to measure the time and check if the constructs would work with FOR-meta-variable expansions. "rem=" or "rem," are still the winner, but even "if %%? == 0" and 'FOR /F %%? in ("%%~?") DO ' are still fast enough Neither "echo>nul" nor "rem^ " can't be used as switchable NOP. Bec...
- 16 Jan 2024 07:08
- Forum: DOS Batch Forum
- Topic: Faster batch macros
- Replies: 17
- Views: 11393
Re: Faster batch macros
@jfl Thanks, your short version of the @Lowsun FOR/F-loop was exactly what I had in mind. But your tests with `if [!!]==[]` has to be failed, because the expression works only at the start detection, but in the end it fails, because then delayed expansion is always enabled and you can't decide with ...
- 16 Jan 2024 05:51
- Forum: DOS Batch Forum
- Topic: FOR /R puzzler? (wildcarded folders only, e.g. A*)
- Replies: 5
- Views: 5465
Re: FOR /R puzzler? (wildcarded folders only, e.g. A*)
I observed something interesting; with one master .bat containing the for, and that for executing do foo.bat "%%G" (the FINDSTR resides in foo.bat), and having ECHO OFF on each .bat, it was still very noisy. Changing that to do CALL foo.bat "%%G" silenced it. Normally I only remember to insert CALL...
- 05 Jan 2024 14:29
- Forum: DOS Batch Forum
- Topic: Faster batch macros
- Replies: 17
- Views: 11393
Faster batch macros
Hi, while I try to build a small batch list selection component for a customer, I stumbled about the horrible, poor performance of batch functions on network drives. My code used the standard :strlen function 180 times and it takes some seconds. I decided to use a strlen macro, it's faster, but stil...
- 01 Jan 2024 14:41
- Forum: DOS Batch Forum
- Topic: infinite loop with break condition
- Replies: 75
- Views: 114878
Re: infinite loop with break condition
Hi Sponge Belly, it's a really nice idea and so simple. And I like the combineable hex values to the total counter. But you inspired me to think about another problem, I want to use the infinite loop in macros where goto can't be used. It can be solved either with an if defined expression or even si...
- 28 Dec 2023 05:54
- Forum: DOS Batch Forum
- Topic: Save command result in a variable
- Replies: 3
- Views: 5134
Re: Save command result in a variable
It fails because percent expansion is evaluated before a code block is executed. Therefore you need delayed expansion here. setlocal EnableDelayedExpansion set "output=" for /f "delims=" %%a in ( 'dism /Online /Get-Capabilities ^| findstr "OpenSSH.Server"' ) do ( set "output=!output!%%a" ) echo !out...
- 27 Dec 2023 05:08
- Forum: DOS Batch Forum
- Topic: Save command result in a variable
- Replies: 3
- Views: 5134
Re: Save command result in a variable
Hi vaschthestampede, the "normal" way is to use the FOR /F command. for /F "delims=" %%A in ('VER') do set "output=%%A" echo output is '%output%' But the part `set output=%%A` is called for each line of the output, therefore only the last line is stored. In your case you should get only one line by ...
- 25 Dec 2023 10:14
- Forum: DOS Batch Forum
- Topic: custom console window banner
- Replies: 4
- Views: 6227
Re: custom console window banner
Hi lazna. Seems even multiline prompt break scripts too :-/ So it looks this concept is wrong from scratch. The obvious way: Don't break scripts by not outputting anything. Output your banner only when you are not in a script. Sounds simple, but then you have to solve the problem of the decision who...
- 12 Dec 2023 07:15
- Forum: DOS Batch Forum
- Topic: Parsing exclamation marks in filenames of %%i
- Replies: 1
- Views: 6071
Re: Parsing exclamation marks in filenames of %%i
Hi RuinedElf , your problem is, that expansion of FOR-variables is only safe when DelayedExpansion is disabled. But working with variables is only safe when DelayedExpansion is enabled. You can solve this by toggling delayed expansion. REM Loop through all MP4 files in the input directory and its su...