Search found 4566 matches
- 15 Jul 2025 13:15
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
The $strlen macro that you have in your test code now is pretty much the same as the latest strLen macro I posted :lol: It's just that yours always expects that delayed expansion is enabled and that $len is the predefined name for the output. Besides of that, yours also handles the 255 characters fo...
- 12 Jul 2025 05:57
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
Addendum: Of course we could call setlocal/endlocal conditionally, depending on whether delayed expansion is already enabled. I changed variable names slightly to mitigate the risk of name clashes. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :initStrLen :: Comput...
- 09 Jul 2025 13:40
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
I don't feel like continuing to try to squeeze out every last hundredth of a second 🤯 That's it for now: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :initStrLen :: Computes the number of bytes in a string. :: %strLen% str len :: str - [ByRef In] Name of the varia...
- 06 Jul 2025 14:54
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
It's really unreadable, and the variable names are, at best, ugly. Agreed. At least I tried to have it consistently ugly :lol: However, it's tricky to get reliable time measurements on a modern system, where the CPU frequency fluctuates constantly. Yeah. To mitigate it I run the tests in realtime p...
- 06 Jul 2025 07:36
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
Some more fiddling 😅 Francesco's approach was not too far away. So I made it a macro and fit for 8191-character strings. It turns out that it works well for very long strings. So I took the part for strings >255 characters and mixed it with the dipstick for <= 255-character strings. Surprisingly the...
- 04 Jul 2025 12:10
- Forum: DOS Batch Forum
- Topic: Deleting hidden and read-only files with pure Batch [SOLVED]
- Replies: 2
- Views: 156
Re: Deleting hidden and read-only files with pure Batch
You mean someting like this?
Steffen
Code: Select all
del /f /a "D:\somewhere\whatever file.ext"
- 03 Jul 2025 10:59
- Forum: DOS Batch Forum
- Topic: strLen boosted
- Replies: 34
- Views: 136696
Re: strLen boosted
It's been too hot to do anything outdoors yesterday. So I came back to this old topic because I remembered Antonio came up with something new last year. I made a few performance comparisons. I turns out that this technique is unfortunately slower than the latest that sowgtsoi posted. Francesco's ada...
- 03 Jul 2025 09:56
- Forum: DOS Batch Forum
- Topic: VBS returns localized TRUE/FALSE
- Replies: 3
- Views: 113
Re: VBS returns localized TRUE/FALSE
You can cast the boolean values in VBS already (using the cint function). This way FALSE becomes 0 and TRUE becomes -1. This said, you should really make the vbs scan the whole file at once. Calling cscript for every line will be horribly slow. Or use JREPL.bat or any other tool with better regex su...
- 01 Jul 2025 12:46
- Forum: DOS Batch Forum
- Topic: Get set /p to accept file suffix.
- Replies: 11
- Views: 887
Re: Get set /p to accept file suffix.
The strategy is simple. 1) If a dot is found in %Suffix%, remove everything that comes before including the dot itself. So "*.xls", ".xls" and "xls" all become "xls" in the first SET statement. (For more information run SET /? and read about environment variable substitution.) 2) Because Get-ChildIt...
- 30 Jun 2025 15:05
- Forum: DOS Batch Forum
- Topic: Get set /p to accept file suffix.
- Replies: 11
- Views: 887
Re: Get set /p to accept file suffix.
Screenshot 2025-06-30 224917.png Screenshot 2025-06-30 225044.png As you can see, SET /P just assignes whatever the user enters. It cannot do anything else. I f you insert these two lines after your SET /P set "Suffix=%Suffix:*.=%" set "Suffix=*.%Suffix%" it doesn't matter if the user omits the ast...
- 30 Jun 2025 12:01
- Forum: DOS Batch Forum
- Topic: Get set /p to accept file suffix.
- Replies: 11
- Views: 887
Re: Get set /p to accept file suffix.
I doubt that this is a cmd issue. It's just the way how the -Filter parameter of the PowerShell Get-ChildItem cmdlet works. It needs the asterisk as a wildcard for the file name. So, what are you trying to do? Manually prepend the asterisk whenever the user didn't enter it?
Steffen
Steffen
- 29 Jun 2025 04:11
- Forum: DOS Batch Forum
- Topic: Get set /p to accept file suffix.
- Replies: 11
- Views: 887
Re: Get set /p to accept file suffix.
Can't repro.
Steffen
Code: Select all
@echo off &setlocal
set "User_Input="
set /p "User_Input=>Enter the 'File Type' [Suffix] including the decimal point and Asterix if applicable and press <Enter>: "
echo %User_Input%
pause
- 22 Jun 2025 06:38
- Forum: DOS Batch Forum
- Topic: How to overcome 32-bits math limitation of BAT if PS1 workaround alerts HIPS repeatedly?
- Replies: 5
- Views: 1213
Re: How to overcome 32-bits math limitation of BAT if PS1 workaround alerts HIPS repeatedly?
Your uncommon 4-digit grouping works incorrectly. It repeats the last digit of the previous group as first digit in the next group. *.ps1 $NUMBER_A = [System.Decimal]1000000000000000000 $NUMBER_B = [System.Decimal]200000000000000000 $Result_in_bytes = $NUMBER_A - $NUMBER_B $KB = $Result_in_bytes / 1...
- 05 Jun 2025 09:35
- Forum: DOS Batch Forum
- Topic: Folder Deletion
- Replies: 1
- Views: 565
Re: Folder Deletion
It's not quite clear to me what you're trying to do. However, you could try something like that: @echo off for /d /r "C:\Users\user\somewhere" %%p in ("*.orph") do ECHO rmdir "%%p" /s /q PAUSE Update the path after the /r option accordingly and run it. The script doesn't do any harm yet, it only dis...
- 01 Jun 2025 11:16
- Forum: DOS Batch Forum
- Topic: Stack Overflow article.
- Replies: 5
- Views: 4189
Re: Stack Overflow article.
Forty years ago, my father used to say, "You young people are getting dumber and dumber. I know the multiplication tables by heart. You even enter 5x5 into your pocket calculator." My father was totally right. Sometimes I can't recall parts of the multiplication tables. Why? Because I don't frequent...