Search found 3577 matches

by aGerman
04 Sep 2019 16:41
Forum: DOS Batch Forum
Topic: rename files in a directory in a batch
Replies: 3
Views: 615

Re: rename files in a directory in a batch

You should exactly define the rules. Even your first example is already ambiguous. The name seems to be separated using dashes which divide it into 4 substrings. Are there always 4 substrings? Is the first substring at least 2 characters long and the second always 6? Does always the 4th substring co...
by aGerman
04 Sep 2019 09:55
Forum: DOS Batch Forum
Topic: retrieving drive details into variables
Replies: 11
Views: 830

Re: retrieving drive details into variables

What I meant is something like that: for /f "tokens=2 delims==:" %%i in ('wmic logicaldisk where "drivetype=5" get DeviceID /value') do ( echo work with %%i here, rather than just echo-ing the drive letter as in this example line ) There are a couple of example powershell scripts I've come across It...
by aGerman
03 Sep 2019 15:43
Forum: DOS Batch Forum
Topic: retrieving drive details into variables
Replies: 11
Views: 830

Re: retrieving drive details into variables

Unfortunately I don't have optical drives on any machine I have access to. Don't have a use for them anymore. Maybe there is a possibility using WMI. But that's something I have to search in the internet, too. I want to get each drive once. Processs them once. But that's exactly what you get in the ...
by aGerman
02 Sep 2019 04:19
Forum: DOS Batch Forum
Topic: retrieving drive details into variables
Replies: 11
Views: 830

Re: retrieving drive details into variables

Batch doesn't support array types. The only kind of an array is a so-called associative array which still consists of single variables. That's something like you try to create using set disk%%i=!optcldsks:~%%i,1! The reason why I assembled the drive letters in a string is that you may want to proces...
by aGerman
01 Sep 2019 11:36
Forum: DOS Batch Forum
Topic: Looking for a specific book
Replies: 16
Views: 1082

Re: Looking for a specific book

Most reddish cover of Batch related books I was able to find. Sorry.
by aGerman
01 Sep 2019 08:18
Forum: DOS Batch Forum
Topic: retrieving drive details into variables
Replies: 11
Views: 830

Re: retrieving drive details into variables

I'm not sure how to get a variable number of drive letters into a variable for each optical drive @echo off setlocal EnableDelayedExpansion set "optcldsks=" set "idx=-1" for /f "tokens=2 delims==:" %%i in ('wmic logicaldisk where "drivetype=2" get DeviceID /value') do set "optcldsks=!optcldsks!%%i"...
by aGerman
01 Sep 2019 07:54
Forum: DOS Batch Forum
Topic: ENABLEDELAYEDEXPANSION exclamation mark
Replies: 3
Views: 643

Re: ENABLEDELAYEDEXPANSION exclamation mark

In your example you don't need ENABLEDELAYEDEXPANSION. Try with DISABLEDELAYEDEXPANSION.
Provide an example that is closer to your real code and where we can see why you actually have trouble...

Steffen
by aGerman
31 Aug 2019 16:31
Forum: DOS Batch Forum
Topic: Multi-line menu with options selection via DOSKEY
Replies: 15
Views: 8687

Re: Multi-line menu with options selection via DOSKEY

Code: Select all

powershell -nop -ep Bypass -c "while($true){$ki=$host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');$vk=$ki.VirtualKeyCode;if(($ki.Character -eq 0) -and ((37..40) -contains $vk)){exit($vk-36);}}"
Maybe that's what you're looking for. Returns errorlevel 1-4.

Steffen
by aGerman
31 Aug 2019 15:31
Forum: DOS Batch Forum
Topic: Looking for a specific book
Replies: 16
Views: 1082

Re: Looking for a specific book

Maybe that's what you're looking for
https://www.amazon.com/Advanced-MS-DOS- ... 830657452/
I don't know any books about Batch though. I just did a quick search on Amazon.

Steffen
by aGerman
31 Aug 2019 13:47
Forum: DOS Batch Forum
Topic: Bit Twiddling Hacks in Batch
Replies: 6
Views: 1066

Re: Bit Twiddling Hacks in Batch

How do you know? Is there a thread about that on these forums? (still 7000+ topics to read ...) No, this is not a subject of this forum. You will find the information somewhere in the depth of the internet. Can't remember where I read it, it's too long ago already. Batch is an interpreted language ...
by aGerman
31 Aug 2019 07:25
Forum: DOS Batch Forum
Topic: Something is running in command prompt on startup.
Replies: 2
Views: 595

Re: Something is running in command prompt on startup.

Run info.bat and post the result. You'll find the link in this sticky thread.

Steffen
by aGerman
31 Aug 2019 07:21
Forum: DOS Batch Forum
Topic: DateExpanded Date Variables all in one package
Replies: 3
Views: 622

Re: DateExpanded Date Variables all in one package

Maybe a few functions out of my collection are helpful for you ... @echo off &setlocal EnableDelayedExpansion for %%i in ("Sunday 0" "Monday 1" "Tuesday 2" "Wednesday 3" "Thursday 4" "Friday 5" "Saturday 6") do for /f "tokens=1*" %%j in (%%i) do set "%%j=%%k"&set "Long%%k=%%j" for /f %%i in ('WMIC P...
by aGerman
30 Aug 2019 14:36
Forum: DOS Batch Forum
Topic: DateExpanded Date Variables all in one package
Replies: 3
Views: 622

Re: DateExpanded Date Variables all in one package

You shouldn't use absolute paths in your scripts. And the GetDate.cmd won't work in a lot of environments around the world. Doesn't work for me btw. The output of time /t is in format DD.MM.YYYY here. Search the forum, we already had lengthy discussions about it.

Steffen
by aGerman
30 Aug 2019 14:17
Forum: DOS Batch Forum
Topic: Bit Twiddling Hacks in Batch
Replies: 6
Views: 1066

Re: Bit Twiddling Hacks in Batch

You used a complicated (decimal) formula in order to convert the errorlevel value in 1-16 range into discrete 1,2,4,8,16 values. I agree that it might not make much sense if you only process the 5 low order bits. But it's not exactly as you think. The "magic" decimal values are bit patterns. (Use t...
by aGerman
29 Aug 2019 14:56
Forum: DOS Batch Forum
Topic: Bit Twiddling Hacks in Batch
Replies: 6
Views: 1066

Re: Bit Twiddling Hacks in Batch

Completely different task - solve a Sudoku puzzle. This is tricky. There are algorithms to find the number using pure logic. But that way you would have to apply a lot of different algorithms and still some patterns are not solvable using logic only. You still would need to use brute force. Brute fo...