Search found 4506 matches

by aGerman
11 Feb 2024 08:19
Forum: DOS Batch Forum
Topic: Macro for Dummies
Replies: 16
Views: 11693

Re: Macro for Dummies

Doubling the length of the variable name reduces the risk of a predefined variable by half. If the risk of having a variable name " " was 0 before, it's only half 0 using " ^". Umm ... wait ... :lol:
idk ¯\_(ツ)_/¯
by aGerman
10 Feb 2024 17:01
Forum: DOS Batch Forum
Topic: Macro for Dummies
Replies: 16
Views: 11693

Re: Macro for Dummies

Perhaps this is going to help you understanding the concept, Saso. 1. What is a Macro? The term "macro" is borrowed from C preprocessing. Values and code can be assigned to a character string there. The C preprocessor then performs a simple text replacement before compilation. This means that wherev...
by aGerman
28 Jan 2024 11:55
Forum: DOS Batch Forum
Topic: Execute a ffmpeg command for each mp3 file in a folder
Replies: 7
Views: 5425

Re: Execute a ffmpeg command for each mp3 file in a folder

@echo off Don't show the prompt and don't repeat the command. setlocal Not necessary. Just one of my defaults to avoid variables to be predefined if I run scripts from a cmd prompt for debugging reasons. for /f "delims=" %%i in FOR /F processes streams line by line. It usually devides a line into t...
by aGerman
28 Jan 2024 09:04
Forum: DOS Batch Forum
Topic: Execute a ffmpeg command for each mp3 file in a folder
Replies: 7
Views: 5425

Re: Execute a ffmpeg command for each mp3 file in a folder

You're about making it an XY problem. Neither do you need to write a text file, nor do you ever need to know the number of files. Just process the output of DIR directly, preferably with a filter that excludes file names containing "4sec". Give that a go: @echo off &setlocal for /f "delims=" %%i in ...
by aGerman
28 Jan 2024 08:39
Forum: DOS Batch Forum
Topic: Faster batch macros
Replies: 17
Views: 12214

Re: Faster batch macros

I found some time to dig a little deeper ... As much as I agree with Arthur Clarke, things are often not that obvious. Especially in highly abstracted languages where you don't know how much complexity is hidden in the implementation of a simple command such like REM, where we already know that it i...
by aGerman
26 Jan 2024 11:06
Forum: DOS Batch Forum
Topic: is there a DOS command for running a program with windows 98 compatibility?
Replies: 11
Views: 11548

Re: is there a DOS command for running a program with windows 98 compatibility?

Even if you don't find anything about it in the internet, it'd be so easy to figure it out. You know where the values are saved in the registry. So, just change the compatibility in the context menu of the executable and observe the updated registry value. Press F5 to reload the regedit interface. S...
by aGerman
26 Jan 2024 11:00
Forum: DOS Batch Forum
Topic: SYSTEM account console 254 characters limit
Replies: 4
Views: 9748

Re: SYSTEM account console 254 characters limit

The console window has no such limits. It's always the command line tool or shell that either spawned the console or is waiting and consuming the input that you enter. All we can do is guessing though. If the console can't be the culprit... The cmd shell has other limits and it would be unlikely tha...
by aGerman
18 Jan 2024 12:28
Forum: DOS Batch Forum
Topic: Faster batch macros
Replies: 17
Views: 12214

Re: Faster batch macros

After reading jfl's timing of the NOP macro, I think we should probably go back to an IF statement. for /f %%! in ("! ^! ^^^!") do ^ set ThisMacro=for %%. in (1 2) do if %%.==2 (%\n% for /f "tokens=2" %%1 in ("%%!%%! 1 0") do (%\n% if 1==%%1 setlocal EnableDelayedExpansion%\n% echo(%%!Args_ThisMacro...
by aGerman
17 Jan 2024 11:17
Forum: DOS Batch Forum
Topic: Faster batch macros
Replies: 17
Views: 12214

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. However, you may find the ans...
by aGerman
16 Jan 2024 12:30
Forum: DOS Batch Forum
Topic: Faster batch macros
Replies: 17
Views: 12214

Re: Faster batch macros

To REM or not to REM that is the question %%~? for /f %%! in ("! ^! ^^^!") do ^ set ThisMacro=for %%. in (1 2) do if %%.==2 (%\n% for /f "tokens=2" %%? in ("%%!%%! "" rem=") do (%\n% %%~?setlocal EnableDelayedExpansion%\n% echo(%%!Args_ThisMacro:~1%%!%\n% %%~?endlocal%\n% )%\n% ) else set Args_ThisM...
by aGerman
26 Oct 2023 11:19
Forum: DOS Batch Forum
Topic: Another amazing porting...
Replies: 14
Views: 91383

Re: Another amazing porting...

OK, got you. setlocal DisableDelayedExpansion set setfont=for /l %%# in (1 1 2) do if %%#==2 (^ %=% for /f "tokens=1-3*" %%- in ("? ^^!arg^^!") do endlocal^&powershell.exe -nop -ep Bypass -c ^"Add-Type '^ %===% using System;^ %===% using System.Runtime.InteropServices;^ %===% [StructLayout(LayoutKin...
by aGerman
26 Oct 2023 09:53
Forum: DOS Batch Forum
Topic: Another amazing porting...
Replies: 14
Views: 91383

Re: Another amazing porting...

PS:There is a little bug in setting the fonts and I hope that aGerman or someone else will help me solve it I don't get what bug you're talking about. Seems to work on my Win11. (only in Conhost of course, not in Windows Terminal as setting the font programmatically is just not foreseen and will pr...
by aGerman
23 Oct 2023 15:58
Forum: DOS Batch Forum
Topic: Is it worth learning Powershell?
Replies: 10
Views: 37343

Re: Is it worth learning Powershell?

tl;dr Yes it's worth learning PS. I think we all have some reasons why we decided to do Batch scripting. For some of us just historical reasons like because we grew up with Batch, we are used to write Batch scripts, we are more experienced with Batch than with other scripting languages, we know how ...
by aGerman
21 Oct 2023 05:28
Forum: DOS Batch Forum
Topic: .lnk shortcut - create programatically
Replies: 5
Views: 20404

Re: .lnk shortcut - create programatically

It's not VBS. It only uses the COM object WScript.Shell which is one out of many that can be instantiated in VBS but not only in VBS. I doubt that they are going to remove COM objects in the near future. FWIW: MS is telling us that they are about to get rid of VBScript while I've not seen anything a...
by aGerman
21 Oct 2023 04:43
Forum: DOS Batch Forum
Topic: i need to check on a branch if it has any files other than desktop.ini
Replies: 8
Views: 23902

Re: i need to check on a branch if it has any files other than desktop.ini

JScript hybrid @if (0)==(0) echo off &setlocal &: Batch/JScript hybrid line :: Batch part: :: That's command to run the script file as JScript again. set ^"playsound=cscript.exe //nologo //e:jscript "%~fs0" ^" :: Recursive check where directories (-d) and system files (-s) are excluded. Typically de...