Search found 227 matches

by jfl
09 Feb 2021 08:31
Forum: DOS Batch Forum
Topic: Cmd.exe bug with special characters
Replies: 2
Views: 3807

Re: Cmd.exe bug with special characters

This is because %0 is the command string you typed, not the actual script name. In the first case, it's quoted, so the special characters do not confuse the echo command. In the second case, it's not quoted, and the special & and ( characters (which have lost their protecting ^ at this stage) do con...
by jfl
08 Feb 2021 01:42
Forum: DOS Batch Forum
Topic: How to get rid of the extra character ahead of the title
Replies: 11
Views: 8712

Re: How to get rid of the extra character ahead of the title

Yes, VT sequences came again with the new console on Win 10. If you need something more downward compatible, try wrapping SetWindowText (SetConsoleTitle didn't work in my tests). No, it's not needed in Windows 7, because the title command in Windows 7 does not add that extra space that is annoying ...
by jfl
07 Feb 2021 13:08
Forum: DOS Batch Forum
Topic: How to get rid of the extra character ahead of the title
Replies: 11
Views: 8712

Re: How to get rid of the extra character ahead of the title

Excellent, thanks! :D I did not know that such Xterm escape sequences worked in the old console too. This seems something new in Windows 10 though, because a quick test in Windows 7 did not work there. Just curious, why do you set that admintitle variable, and invoke it as a second command afterward...
by jfl
29 Jan 2021 14:58
Forum: DOS Batch Forum
Topic: MODE CON:...
Replies: 2
Views: 3053

Re: MODE CON:...

Could it be that the 'mode con' moves the cursor to the top left corner every time?
by jfl
27 Jan 2021 12:42
Forum: DOS Batch Forum
Topic: How to get rid of the extra character ahead of the title
Replies: 11
Views: 8712

How to get rid of the extra character ahead of the title

As search does not work anymore on the forum (Anybody looking at this?), I'm turning to other peoples' memory... I noticed that the title command inserts an extra space in front of the title string. By default, my cmd console has the title: Administrator: Command Prompt But if I run: title Command P...
by jfl
27 Jan 2021 12:14
Forum: DOS Batch Forum
Topic: A script making it easy to set a variable with the output of a command
Replies: 3
Views: 3675

Re: A script making it easy to set a variable with the output of a command

I've updated $.bat . It now creates a list with one entry for each non-empty line in the command output. This makes it really usable for the Docker scenarios that motivated me to begin this effort. Entries that contain spaces or special characters are quoted. This allows looping on the list. Ex: C:\...
by jfl
25 Jan 2021 08:10
Forum: DOS Batch Forum
Topic: SORT /UNIQUE /UNI_OUTPUT...
Replies: 4
Views: 4298

Re: SORT /UNIQUE /UNI_OUTPUT...

Ah, OK!
I expected it would output strings like case-dependent sorts in Unix:

Code: Select all

ABC
XYZ
abc
xyz
I just checked /CASE_SENSITIVE is present in XP and later versions of Windows, but not in Windows 98. Funny I never heard of it.
by jfl
25 Jan 2021 06:35
Forum: DOS Batch Forum
Topic: SORT /UNIQUE /UNI_OUTPUT...
Replies: 4
Views: 4298

Re: SORT /UNIQUE /UNI_OUTPUT...

I think that TEMP and path are not part of the supported options. /TEMP worked for you as an abbreviation of the documented /TEMPORARY option. Also note that contrary to the other options before it, it is part of a longer string "TEMP path": C:\Windows\System32>strings sort.exe | ag "[a-z]{4,}" [Uni...
by jfl
24 Jan 2021 09:15
Forum: DOS Batch Forum
Topic: Request for help to speed up batch program for 17,000 TXT files
Replies: 6
Views: 5677

Re: Request for help to speed up batch program for 17,000 TXT files

For quickly searching for strings in a large set of text files, try The Silver Searcher . The ag.exe program in that zip file is a port for Windows that I maintain, of the Unix tool ag. It supports full fledged regular expressions, so finding any sequence of valid characters you can think of will be...
by jfl
24 Jan 2021 08:45
Forum: DOS Batch Forum
Topic: RPN.exe: Floating-point arithmetic operations in Reverse Polish Notation
Replies: 4
Views: 5246

Re: RPN.exe: Floating-point arithmetic operations in Reverse Polish Notation

I gave it a try, and it's indeed nice and easy to use for doing calculations at the command prompt. :) The rpn.exe executable is surprisingly small. Was it all written in assembly language? The stack-based RPN notation reminds me a lot of the old Forth programming language. Add support for strings, ...
by jfl
22 Jan 2021 12:45
Forum: DOS Batch Forum
Topic: A script making it easy to set a variable with the output of a command
Replies: 3
Views: 3675

Re: A script making it easy to set a variable with the output of a command

No, you still can't nest them, but you can get the same effect very easily:

Code: Select all

$ VAR1 innermost_command
$ VAR2 middle_command %VAR1%
outer_command %VAR2%
So, yes, three commands instead of one. But barely more characters to type overall than in Bash or PowerShell.
by jfl
22 Jan 2021 10:47
Forum: DOS Batch Forum
Topic: A script making it easy to set a variable with the output of a command
Replies: 3
Views: 3675

A script making it easy to set a variable with the output of a command

Unix shells, and Windows own PowerShell, allow nesting commands inside each other using the $(subcommand) syntax. This syntax is extremely convenient for capturing the output of a subcommand, and passing it as an argument to an outer command. For example, using Docker, you can find containers that h...
by jfl
18 Jan 2021 02:22
Forum: DOS Batch Forum
Topic: Issue with executing a command in parallel
Replies: 2
Views: 2816

Re: Issue with executing a command in parallel

You should use a Win32 port of the Unix tail utility. It's designed precisely to do what you want to do. There's one coming with git for Windows, if you have it. Typically in "C:\Program Files\Git\usr\bin\tail.exe". Else you can find a tail.exe in old win32 ports like UnxUtils or GnuWin32 . Then the...
by jfl
11 Jan 2021 09:16
Forum: DOS Batch Forum
Topic: Is there a way to make a bootable batch file?
Replies: 5
Views: 5206

Re: Is there a way to make a bootable batch file?

This existed in MS-DOS, and was called AUTOEXEC.BAT: The first thing MS-DOS did after booting was to automatically run AUTOEXEC.BAT. Now you can still legally do that using FreeDOS. Windows is different. It is not an open-source operating system. Its commercial license forbids you to copy it to anot...
by jfl
08 Jan 2021 07:09
Forum: DOS Batch Forum
Topic: ERRORLEVEL and Where.exe program
Replies: 2
Views: 2898

Re: ERRORLEVEL and Where.exe program

It's also possible to do that without invoking the where.exe program at all. Ex: C:\JFL\Temp>for %p in (notepad.exe) do @echo set N=%~$PATH:p set N=C:\Windows\System32\notepad.exe C:\JFL\Temp>for %p in (nothing.exe) do @echo set N=%~$PATH:p set N= C:\JFL\Temp> In a batch file, it'd become: for %%p i...