Search found 6 matches

by bluesxman
2022-Aug-04, 5:13 pm
Forum: Windows CMD Shell
Topic: How to replace all characters in a variable with another character?
Replies: 2
Views: 76

Re: How to replace all characters in a variable with another character?

I don't think there's a straight forward way to do that. You could use this https://ss64.com/nt/syntax-strlen.html To measure the string length and then form a string of * of the right length So, for example: @echo off set "foo=qwertyuiop" set "bar=" call :strlen foo foo_len setl...
by bluesxman
2022-May-13, 11:21 am
Forum: Windows CMD Shell
Topic: position variables in substring extraction use octal number recognition
Replies: 1
Views: 293

Re: position variables in substring extraction use octal number recognition

Interesting, don't remember noticing that before ... but doesn't altogether come as a surprise, given that other numeric handling interprets octal. S:\>if 8 EQU 010 echo hello octal hello octal S:\>set /a x=010 8 Good to know for potential gotchas though! There is, however, an interesting divergence...
by bluesxman
2022-Apr-14, 8:45 am
Forum: Windows CMD Shell
Topic: How to differentiate between similar filename extensions?
Replies: 6
Views: 776

Re: How to differentiate between similar filename extensions?

Maybe something like this?

Code: Select all

for %%F in (*) do set /a "EXT%%~xF+=1"
set EXT.
This should count all the extensions, if you only care about a few you can just pick those up like %EXT.jpe%
by bluesxman
2022-Apr-12, 3:36 pm
Forum: Windows CMD Shell
Topic: How to differentiate between similar filename extensions?
Replies: 6
Views: 776

Re: How to differentiate between similar filename extensions?

I don't think it's treating it as a wildcard exactly, I think you're probably coming up against weirdness from 8.3 filenames S:\>dir /x <snip> 12/04/2022 16:32 2 hello.jpe 12/04/2022 16:32 2 HELLO~1.JPE hello.jpeg 12/04/2022 16:32 2 hello.txt 12/04/2022 16:32 2 HELLO~1.TXT hello.txt1 12/04/2022 16:3...
by bluesxman
2021-Sep-06, 7:16 am
Forum: Windows CMD Shell
Topic: How to create a variable with arguments starting at 2 positions ?
Replies: 4
Views: 3908

Re: How to create a variable with arguments starting at 2 positions ?

I agree, it feels like there should be a more elegant solution -- but keeping it robust is tricky without knowing more about the expected input. The only other thing I had in mind was a FOR loop, but it doesn't look any better to me (while probably being marginally worse on performance due to the re...
by bluesxman
2021-Sep-03, 11:21 am
Forum: Windows CMD Shell
Topic: How to create a variable with arguments starting at 2 positions ?
Replies: 4
Views: 3908

Re: How to create a variable with arguments starting at 2 positions ?

SHIFT set arguments=%* I don't think that will work Simon, AFAIK %* always contains all of the original args, regardless of "shift" invocations. You'd probably have to do something like this: @echo off set "args=" call :argloop %* set args goto :EOF :argloop shift if "%~1&q...