Search found 52 matches

by Rekrul
2023-Mar-15, 3:28 am
Forum: Windows CMD Shell
Topic: Are there any scripts that DEPEND on NOT using Delayed Expansion?
Replies: 6
Views: 6629

Re: Are there any scripts that DEPEND on NOT using Delayed Expansion?

If you think you might encounter a filename that contains an exclamation point, then disable it. Thankfully, most normal people don't put exclamation points in their filenames unless they're working with ROMs or something, so it's largely a non-issue. Sometimes I use exclamation points to cause tho...
by Rekrul
2023-Mar-14, 8:15 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27649

Re: Use SED to extract part of a line?

No need to use external tools. Thank you for the reply. I actually found this solution (using quotes as a deliminator) through a Google search the other day, and finished my script. Well, "finished" in the sense that it works. Now I'm going to polish it and add some options. For those who...
by Rekrul
2023-Mar-12, 11:07 pm
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27649

Re: Use SED to extract part of a line?

SED is a stream editor intended to modify a files contents rather than extracting values from it. OK. I thought that since it could be restricted to individual lines, it would be a good choice for extracting part of a specific line. if you want to use bash utilities, I would start by using head and...
by Rekrul
2023-Mar-12, 11:35 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27649

Use SED to extract part of a line?

I know this isn't really a Windows CMD command question, but I'm not sure where else to post this. Every time I try to post a question to a site like Stack Exchange, I'm usually told I posted in the wrong section, or I just get directed to a post asking a similar, but not quite the same, question, w...
by Rekrul
2023-Mar-09, 6:27 am
Forum: Windows CMD Shell
Topic: Are there any scripts that DEPEND on NOT using Delayed Expansion?
Replies: 6
Views: 6629

Re: Are there any scripts that DEPEND on NOT using Delayed Expansion?

The only time you really need to disable delayed expansion is when you're working with filenames that contain exclamation points. Yes, but since you never know ahead of time whether a filename will contain an exclamation point, leaving Delayed Expansion on all the time can cause any script that dea...
by Rekrul
2023-Mar-07, 2:56 am
Forum: Windows CMD Shell
Topic: Are there any scripts that DEPEND on NOT using Delayed Expansion?
Replies: 6
Views: 6629

Are there any scripts that DEPEND on NOT using Delayed Expansion?

Just a theoretical question... I'm given to understand that Windows batch scripts don't use Delayed Expansion in order to maintain backwards compatibility with older scripts, which didn't have it. As a result, inside loops, or when inside parenthesis, only the existing value of a variable can be rea...
by Rekrul
2023-Mar-07, 2:38 am
Forum: Windows CMD Shell
Topic: Is there any way to modify a variable twice in the same IF comparison?
Replies: 7
Views: 7158

Re: Is there any way to modify a variable twice in the same IF comparison?

If you do not use delayed expansion and you are within a code block use ' call set ' to use the updated value of a variable changed within the code block. Damn, I thought I had tried that. Then again, I swear sometimes that something that doesn't work one day, will work the next. Thanks. read this ...
by Rekrul
2023-Mar-07, 2:31 am
Forum: Windows CMD Shell
Topic: Batch Script not Executing filename + Parameters
Replies: 4
Views: 85821

Re: Batch Script not Executing filename + Parameters

however I still would like for it to, after it asks for me to browse for the file, echo gcc %thefilename%.c -o %thefileame.exe and then execute that. I'm curious: Why do you want to print the command to the actual command prompt and then have the user press a key to execute it? I understand the ide...
by Rekrul
2023-Mar-02, 12:37 am
Forum: Windows CMD Shell
Topic: Is there any way to modify a variable twice in the same IF comparison?
Replies: 7
Views: 7158

Re: Is there any way to modify a variable twice in the same IF comparison?

In your second script you have call if %x% equ 1 ( call if is not supported (nor is CALL FOR, see https://ss64.com/nt/call.html ) I wasn't sure, I was just trying things I thought might work. If you remove the CALL then it works as expected. Not quite. If you remove call from the second example, it...
by Rekrul
2023-Mar-01, 1:06 pm
Forum: Windows CMD Shell
Topic: Is there any way to modify a variable twice in the same IF comparison?
Replies: 7
Views: 7158

Is there any way to modify a variable twice in the same IF comparison?

Is there any way you can modify a variable twice as the result of a single if comparison, WITHOUT using Delayed Expansion? For example; @echo off set x=1 set test=Hello if %x% equ 1 ( set test=Hi set test=%test% There ) echo %test% This prints Hello There if the comparison is true, and just Hello if...