Search found 196 matches

by Sponge Belly
27 Oct 2014 04:15
Forum: DOS Batch Forum
Topic: Create nul and all ascii characters with only batch
Replies: 110
Views: 52564

Re: Create nul and all ascii characters with only batch

Hi Squashman, Dave Benham first proposed using forfiles to generate nearly any character, including tab 2 years ago. As noted at the time, the trouble with forfiles is that it isn’t present on all versions of Windows. Makecab, otoh, is. So my little snippet should work out-of-the-box on XP and above...
by Sponge Belly
26 Oct 2014 12:53
Forum: DOS Batch Forum
Topic: Create nul and all ascii characters with only batch
Replies: 110
Views: 52564

Re: Create nul and all ascii characters with only batch

Hello All! I modified the code developed in this thread to store a tab in a variable: @echo off & setlocal enableextensions disabledelayedexpansion type nul >tab.tmp makecab /d compress=off /d reserveperdatablocksize=0 ^ /d reserveperfoldersize=9 tab.tmp tab.tmp >nul for /f "skip=28 delims=...
by Sponge Belly
25 Oct 2014 06:56
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 9604

Re: robust line counter

Penpen wrote: I assume the safest way is, to to use fc.exe and count the hex newline characters and add 1 to get the linecount.
That’s what made me think you were incorrectly adding 1 to the line count when a file ended with a LF. Sorry I misunderstood.
by Sponge Belly
24 Oct 2014 12:41
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 9604

Re: robust line counter

Argh! Hoisted by my own petard . I neglected the edge-case of a file whose last line is a single non-LF character. See this post for revised code. @Penpen Using fc /b to count the LFs in a file is an interesting approach, but you fell into the same trap I did. Your code counts the number of LFs and ...
by Sponge Belly
21 Oct 2014 10:27
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 9604

Re: robust line counter

Thanks to everyone who replied… @Siberia-Man More has problems as pointed out by Squashman above and in this post . Type would be a better alternative: type filename.txt | find /c /v "" @FoxiDrive Using redirected input from a file with find is unreliable… as you yourself discussed in this...
by Sponge Belly
20 Oct 2014 07:44
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 9604

Re: robust line counter

Jump to this post for the latest version of the subroutine.
by Sponge Belly
19 Oct 2014 10:18
Forum: DOS Batch Forum
Topic: Another way to create a line feed variable
Replies: 8
Views: 4596

Re: Another way to create a line feed variable

Hello All! In a post on another topic , Dave Benham observed: SET /P will terminate the input upon reading a NULL byte. What really blows me away is that SET /P can read both newline (0x0A) and carriage return (0x0D) into a variable if they are followed by 0x00. With the caveat that there has to be ...
by Sponge Belly
15 Sep 2014 14:30
Forum: DOS Batch Forum
Topic: create dummy files of exact size
Replies: 15
Views: 6929

Re: create dummy files of exact size

Hi Again! Sorry for the delay, but I’m easily… oh look, a shiny object! Anyways, I’ve rewritten the code to create a dummy file that has the same size as the original. The program accepts two arguments: the original filename (required); and the ASCII code of the fill character (0 by default). If all...
by Sponge Belly
26 Aug 2014 14:08
Forum: DOS Batch Forum
Topic: A different method to trim spaces from a string
Replies: 16
Views: 7900

Re: A different method to trim spaces from a string

Hello All! I reread this topic and felt there must be a way to coax %* into right-trimming an arbitrary string. I played around with the code of some of the contributors and discovered that CALL doesn’t enforce a closing quote for the parameter passed to a subroutine. The following kludgy code illus...
by Sponge Belly
22 May 2014 17:02
Forum: DOS Batch Forum
Topic: Get only first row for each file
Replies: 10
Views: 6936

Re: Get only first row for each file

Hello All! Sorry to revive an old topic, but avery_larry seems to be saying that the following: for /f "usebackq delims=" %%f in ("file.txt") do ( echo(%%f goto break ) :break (rest of program) will display the first non-empty line of file.txt without the overhead of expanding th...
by Sponge Belly
14 May 2014 14:27
Forum: DOS Batch Forum
Topic: create dummy files of exact size
Replies: 15
Views: 6929

Re: create dummy files of exact size

Wow! Thanks to everyone for their great feedback. @Einstein1969: Interesting approach. I mean to put your code under the microscope when I have more time. A quick test on a file 1049 bytes long created dd.tmp which was also 1049 bytes. Unfortunately, another file called d.tmp was left over after exe...
by Sponge Belly
14 May 2014 05:49
Forum: DOS Batch Forum
Topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
Replies: 38
Views: 91960

Re: ECHO. FAILS to give text or blank line - Instead use ECH

Hi Liviu!

Thanks for the explanation.

But why doesn’t…

Code: Select all

(call;>>file.txt)


clobber the SUB at the end of file.txt?

- SB
by Sponge Belly
14 May 2014 03:42
Forum: DOS Batch Forum
Topic: Attempt to catch arrow keystrokes
Replies: 21
Views: 9787

Re: Attempt to catch arrow keystrokes

Hello All!

This post on how to mute sound volume is worth reading.

- SB
by Sponge Belly
10 May 2014 16:53
Forum: DOS Batch Forum
Topic: expert status
Replies: 1
Views: 910

expert status

Hello All,

Does anyone know what the procedure is for changing someone’s status to expert? I think Carlos, FoxiDrive, Penpen and Squashman should all be experts. Who decides? How is it done? Why weren’t they made experts long ago?

- SB
by Sponge Belly
10 May 2014 16:45
Forum: DOS Batch Forum
Topic: create dummy files of exact size
Replies: 15
Views: 6929

create dummy files of exact size

Hello All! Apropos nothing, here’s a working draft of a subroutine to create a dummy file with the exact size of the original. Works up to the Batch limit. Never more than 58 passes (I think!) and no use of goto. The idea is simple enough: keep all the temp files that double in size until the power ...