Search found 52 matches

by Rekrul
2024-Mar-05, 11:10 pm
Forum: Windows CMD Shell
Topic: Is there any universal way to redirect file operations to nul?
Replies: 4
Views: 487

Re: Is there any universal way to redirect file operations to nul?

I think it depends on the program you run? As soon as you start a program, cmd is no longer in control. That is, you can suppress the console output of a program (most of the times), but I don't think you can fiddle with any data operations the program performs. OK. I was just thinking that Windows...
by Rekrul
2024-Feb-18, 2:34 am
Forum: Windows CMD Shell
Topic: Is there any universal way to redirect file operations to nul?
Replies: 4
Views: 487

Re: Is there any universal way to redirect file operations to nul?

My first thought would be to create a RAM Disk and direct all writes to that, they are very fast and will be automatically wiped at next reboot, so perfect for temporary storage. Writing to RAM avoids having a lot of read/writes to your SSD but at the cost of using some RAM. OK, so there's no built...
by Rekrul
2024-Feb-17, 8:53 am
Forum: Windows CMD Shell
Topic: Is there any universal way to redirect file operations to nul?
Replies: 4
Views: 487

Is there any universal way to redirect file operations to nul?

You can redirect text and error output to nul, but is there any way to force operations that would normally write to a file, to write to nul instead? I know you can do; copy file.ext nul But what about commands where you don't specify an output/destination filename, like archive programs? Many of th...
by Rekrul
2023-Dec-11, 7:19 am
Forum: Windows CMD Shell
Topic: What is the best way to check for a disc in an optical drive?
Replies: 2
Views: 2029

What is the best way to check for a disc in an optical drive?

I have a couple methods of doing this, but I was wondering if there was an 'official' method of checking to see if there's a disc in an optical drive?
by Rekrul
2023-Dec-11, 7:16 am
Forum: Windows CMD Shell
Topic: FOR loop : make it stop itself
Replies: 2
Views: 2970

Re: FOR loop : make it stop itself

FOR /f "tokens=4,5" %i in (file.txt) DO if %j == sometext echo %i %j outputs desired content, but I want processing to quit upon first occurrence, and not by exiting the console. You can do it inside a script; @echo off FOR /f "tokens=4,5" %%i in (file.txt) DO ( if "%%j&quo...
by Rekrul
2023-Sep-16, 1:12 am
Forum: Windows CMD Shell
Topic: Command line utility to edit ini files?
Replies: 6
Views: 36391

Re: Command line utility to edit ini files?

NirCMD has the ability to modify ini files. However, it doesn't offer a way to check for existing values. So I went out to search for a command line utility with that capability. 'Initool' popped up but it doesn't work - at least not with Windows cmd. Couldn't find anything else? I just tested Init...
by Rekrul
2023-Sep-15, 4:55 am
Forum: Windows CMD Shell
Topic: Windows port of GSAR causes FOR loop to repeat on USB flash drives?
Replies: 2
Views: 42211

Re: Windows port of GSAR causes FOR loop to repeat on USB flash drives?

Pretty weird? Does this happen to anyone else, or is it just me? Not an answer to your question, but I use FNR (Find and Replace). gsar can do more than just replace text. It will process any type of file and replace whatever you tell it. Aside from plain text, the characters to search and replace ...
by Rekrul
2023-Sep-02, 5:58 am
Forum: Windows CMD Shell
Topic: Windows port of GSAR causes FOR loop to repeat on USB flash drives?
Replies: 2
Views: 42211

Windows port of GSAR causes FOR loop to repeat on USB flash drives?

The script below uses a Windows port of GSAR to perform a search and replace operation on all the TXT files in the current directory. It changes the word "test" to "text". If I run this script on files on a hard drive, either internal or external USB, it works perfectly. Each fil...
by Rekrul
2023-Aug-11, 1:21 am
Forum: Windows CMD Shell
Topic: Does "endlocal" close all instances of "setlocal"?
Replies: 6
Views: 10332

Re: Does "endlocal" close all instances of "setlocal"?

Just as a matter of habit, even for scripts which don't (yet) contain any variables. If you run a script from a CMD session and it sets variables without using Setlocal, then those variables stick around after the script finishes. Run a few such scripts and you can have an environment filled with a...
by Rekrul
2023-Jul-27, 8:25 am
Forum: Windows CMD Shell
Topic: Use SED to extract part of a line?
Replies: 10
Views: 27639

Re: Use SED to extract part of a line?

And once again, I found bugs and shortcomings in my script. It wasn't correctly counting the NZB files in the directory if run from an open window because the set command to clear the variable was in the wrong place. It also didn't correctly recognize filenames with exclamation points due to my usin...