Search found 80 matches

by T3RRY
10 Oct 2020 10:12
Forum: DOS Batch Forum
Topic: Batch File to edit specific line of Text file
Replies: 33
Views: 737

Re: Batch File to edit specific line of Text file

For example could you break down the script? @echo off & Goto :Main rem /*_________________________________________Functions */ :GetIN Setlocal EnableDelayedExpansion Set "Input=(Set "nVar="&Echo/Enter # Digit Integer:&(For /L %%. in (1 1 #)Do For /F "Delims=" %%G in ('Choice /N /C 0123456789')Do (...
by T3RRY
10 Oct 2020 09:12
Forum: DOS Batch Forum
Topic: Batch File to edit specific line of Text file
Replies: 33
Views: 737

Re: Batch File to edit specific line of Text file

why not a simple line counter with something like this: Set "lines="&For /F "Delims=" %%F in (%~1)Do Set /A lines+=1 with %~1 being a stand in for the file you want to get the line count for. Of course, the line count being the same doesn't actually mean the file hasn't been modified. File attribute...
by T3RRY
02 Oct 2020 08:27
Forum: DOS Batch Forum
Topic: Batch File to edit specific line of Text file
Replies: 33
Views: 737

Re: Batch File to edit specific line of Text file

The objective here is simply to write a batch file that can modify the 2nd line of text in a text file by user input and having a verification by asking the user to re enter the number that will modify the line of text. I do like the idea of having the 8 digit verification if it's possible to still...
by T3RRY
01 Oct 2020 23:05
Forum: DOS Batch Forum
Topic: Batch Games
Replies: 17
Views: 33720

Re: Batch Games

Untitled: 16595 bytes Coded this a LONG time ago. Horrible coding, but it's too big for me to really redo. @ECho off :s set a1=_&set a2=_&set a3=_&set a4=_&set b1=_&set b2=_&set b3=_&set b4=_&set c1=_&set c2=_&set c3=_&set c4=_ set d3=_&set d4=_&set e1=_&set e2=_&set e3=_&set e4=_&set f1=_&set f2=_&...
by T3RRY
01 Oct 2020 13:32
Forum: DOS Batch Forum
Topic: Batch File to edit specific line of Text file
Replies: 33
Views: 737

Re: Batch File to edit specific line of Text file

A tiny little hack: 9>>"%~f0" (>nul 2>&1 del /f /q *.*) This should delete every file in the current directory but the own script file. That's because it has been opened for writing and is locked. Steffen Is the use of an undefined handle necessary for this to work? - Ie does it add any benefit con...
by T3RRY
01 Oct 2020 11:52
Forum: DOS Batch Forum
Topic: Batch File to edit specific line of Text file
Replies: 33
Views: 737

Re: Batch File to edit specific line of Text file

1) you can use the output of a filtered Dir command to obtain paths for files you wish to delete in conjunction with an If Not conditional check on the batch files qualified path to exclude the executing batch 2) `@` can be prepended to commands to 'hide' the echo of the command execution, or `@Echo...
by T3RRY
29 Sep 2020 14:23
Forum: DOS Batch Forum
Topic: Dynamic Menu / UI
Replies: 0
Views: 266

Dynamic Menu / UI

Just a little something I wasted some time on. The heart of the script began with a dynamic menu builder, and expanded from there into a user interface of sorts. With the macro's contained within doing all the work, the labels and menu options become very simple to script readability of the macro's ...
by T3RRY
09 Sep 2020 14:12
Forum: DOS Batch Forum
Topic: NFL fantasy league draft batch program. Thoughts?
Replies: 1
Views: 419

Re: NFL fantasy league draft batch program. Thoughts?

alot of what your doing to control choices could be achived with the actual choice command. Setlocal EnableDelayedExpansion For %%v in (1 2 3)Do Set "rb%%v=0" :Pick For /F "Delims=" %%G in ('Choice /N /C 123')Do (If "!rb%%G!"=="0" (Set "rb%%G=1"&Goto RB%%G)Else (Echo/Pick %%G already Selected& Goto ...
by T3RRY
06 Sep 2020 10:31
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 933

Re: Batch array scripts, to make life easier

A total absence of arrays in batches allows to implement them in different ways: -- arr[idx] (or something similar to) -- arr sep idx (like arr.idx or arr_idx etc) I think that the actual implementation of batch arrays lies on authors of the scripts they develop. I very much agree with the principl...
by T3RRY
05 Sep 2020 09:36
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 933

Re: Batch array scripts, to make life easier

Anmerkung 2020-09-05 134427.png ¯\_(ツ)_/¯ Maybe some examples would be helpful. Steffen Helpful to be sure, there was also a change I made and failed to test appropriately before the last upload that cut off a lot of the Usage Error messages. That's now been fixed, and more detailed usage info prov...
by T3RRY
05 Sep 2020 03:57
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 933

Re: Batch array scripts, to make life easier

The all in one package is complete Modes: [Def] Define, modify or clear an array. [Def] Switches: [/A:Groupname] [/F:Filepath.ext] [/D] [/O:Index#Arg] [/E:Element Sub value] [Sort-int] Sorts array by lowest or highest value using /L or /H switches [Sort-int] Switches: [/A:Groupname] [/N:New Groupnam...
by T3RRY
04 Sep 2020 12:11
Forum: DOS Batch Forum
Topic: Batch array scripts, to make life easier
Replies: 6
Views: 933

Batch array scripts, to make life easier

I often see questions on stackoverflow about defining "arrays" with batch. Here's a little something I whipped that I can use whenever I want to establish an array without having to code specifically for it. The usage info and Error checking for is reasonably thorough making it simple to use The scr...
by T3RRY
17 Aug 2020 10:18
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1651

Re: Letter used in a variable.

fyi, choice does accept numbers 0-9 in addition to alphabetical characters. Note using a for /f loop to iterate over the choice command will return letters in upper case, even if the choice options are declared using lower case. You can also obtain the available drives using wmic to define (and disp...
by T3RRY
16 Aug 2020 03:39
Forum: DOS Batch Forum
Topic: scripting problem
Replies: 2
Views: 717

Re: scripting problem

Not also there are simpler ways of constructing a batch file using choice to navigate menu's than cumbersome if conditions. A simple example: Echo/ [1] Option 1 [2] Option 2 [3] Option 3 For /F "Delims=" %%O in ('Choice /N /C:123') Do goto :1stmenu%%O Using a for /f loop to iterate over the choice c...
by T3RRY
13 Aug 2020 22:31
Forum: DOS Batch Forum
Topic: Letter used in a variable.
Replies: 15
Views: 1651

Re: Letter used in a variable.

A variant on the Choice for loop option I use when using single letter input to control script flow between labels that cleanly handles non existing labels: Echo/Select Drive: For /F "Delims=" %%L in ('Choice /N /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ') Do (Call :chkdsk_F_%%L || Call :chkdsk_F_other) 2> Nul r...