Search found 199 matches

by Sponge Belly
04 Jul 2013 13:21
Forum: DOS Batch Forum
Topic: DISKPART UNIQUEID=GUID failure. Why ? Any Alternatives ?
Replies: 2
Views: 4551

Re: DISKPART UNIQUEID=GUID failure. Why ? Any Alternatives

Hi Alan! :-)

Wow! I didn’t understand a word of that. Sounds like the kind of thing Fred Langa of Windows Secrets fame would sink his teeth into. Or have you solved the problem on your own in the meantime? Don’t leave us hanging in suspense! ;-)

- SB
by Sponge Belly
04 Jul 2013 13:09
Forum: DOS Batch Forum
Topic: Automation of Microsoft Forefront Endpoint Protection
Replies: 1
Views: 1484

Re: Automation of Microsoft Forefront Endpoint Protection

Hi KidHaxMan!

What did you type into Google? I just tried “microsoft forefront command line” and got lots of promising results.

Good luck! :-)

- SB
by Sponge Belly
04 Jul 2013 13:00
Forum: DOS Batch Forum
Topic: Help with batch file - combine 2 files
Replies: 1
Views: 1573

Re: Help with batch file - combine 2 files

Hello Rookie! Just noticed your post in the list of unanswered topics. You probably didn’t get any replies because you weren’t specific enough. Are the two files you wish to merge text files? Could you give a sample of both? And how do you want them merged? One after the other, or side by side? - SB
by Sponge Belly
02 Jul 2013 15:33
Forum: DOS Batch Forum
Topic: %~z1 question
Replies: 6
Views: 4293

%~z1 question

Dear DosTips, Please peruse the following snippet: if "%~1" neq "" ( if %~z1 equ 0 ( echo(file is empty ) else echo(file is not empty ) else echo(no cmdline args found If a filename is supplied on the command line, all is well. But if no filename is specified, the program throws ...
by Sponge Belly
02 Jul 2013 13:13
Forum: DOS Batch Forum
Topic: var inside for /f loop’s in (…) clause
Replies: 3
Views: 1799

Re: var inside for /f loop’s in (…) clause

Thanks Dave! The scary thing is that I actually understood your explanation. Another little piece of the puzzle has fallen into place. Anyways, for anyone still reading this topic, to make the LF variable work inside the for /f loop’s in (…) clause using delayed expansion, you would have to do the f...
by Sponge Belly
02 Jul 2013 07:10
Forum: DOS Batch Forum
Topic: var inside for /f loop’s in (…) clause
Replies: 3
Views: 1799

var inside for /f loop’s in (…) clause

Hello All! The little snippet below outputs the number and contents of any lines found in a user-specified file that don’t contain a Line Feed. And then it does it again. First using a bare findstr, and then using findstr wrapped inside a for /f loop’s in (…) clause. @echo off & setlocal enablee...
by Sponge Belly
16 Jun 2013 15:29
Forum: DOS Batch Forum
Topic: new findstr bug
Replies: 20
Views: 11535

new findstr bug

Dear DosTips, I tried piping a single character into findstr using set /p, type, and findstr itself. The results were the same: absolutely nothing! findstr silently gobbled it up. > <nul set /p "=#" | findstr /n "^" (no output) > <nul set /p "=##" | findstr /n "^&q...
by Sponge Belly
13 Jun 2013 13:11
Forum: DOS Batch Forum
Topic: [Solved] find or findstr prompt issue
Replies: 11
Views: 6552

Re: [Solved] find or findstr prompt issue

Hello All! Apologies for my late arrival to this topic. I hope it goes better than the last time I tried to revive an old thread! Anyways, Allal makes a valid point. However, there is a Batch solution to Bouchta’s problem. The following little program accepts a filename as argument and runs findstr ...
by Sponge Belly
25 May 2013 11:50
Forum: DOS Batch Forum
Topic: truncate files - a (pure?) batch solution
Replies: 3
Views: 5141

truncate files - a (pure?) batch solution

Hello All! Sometimes I’d like to snip off the newline from the end of a file. But there’s no efficient way to do it using pure Batch commands. Recently, I unearthed a Super User question on how to truncate a set amount of bytes from a file . The second answer gave a PowerShell solution. I know nothi...
by Sponge Belly
13 May 2013 10:00
Forum: DOS Batch Forum
Topic: How to detect if input comes from pipe or redirected file
Replies: 9
Views: 5933

Re: How to detect if input comes from pipe or redirected fil

Hello Jeb! Only found this earlier topic today. But my question still stands: I’m looking for a robust method to check for redirected input (ie, prog.cmd < file.txt). The program in the OP correctly identifies redirected input from a file. But like FPW says in the comments, it’s fragile, requires a ...
by Sponge Belly
05 May 2013 15:04
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 11670

Re: robust line counter

Dammit, Foxi. You’re right. If a colon comes after a null character on a line of output from findstr /n "^" "%~1", find /c ":" will count it as two lines. That torpedos Ranguna173’s otherwise elegant solution. As to your second point, try this (note the null character o...
by Sponge Belly
04 May 2013 14:20
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 11670

Re: robust line counter

Hi Foxi! Had a look at your test file. It has four lines. The fourth line doesn’t end with a CR+LF, but it still counts. Get a hex dump from certutil if you don’t believe me. I tried both mine and Ranguna173's code on a test file with null characters at the beginning, middle and end of lines. They w...
by Sponge Belly
04 May 2013 05:42
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 11670

Re: robust line counter

Hi Again! Thanks for your replies. @Foxi: I did too run tests. One thing I discovered is that find turns null characters into newlines which causes an incorrect count. @Squashman: You’re right, of course. Good old find /c /v "" < file is just fine… 99% of the time. My code is an attempt to...
by Sponge Belly
03 May 2013 13:09
Forum: DOS Batch Forum
Topic: robust line counter
Replies: 22
Views: 11670

robust line counter

Below is a little program to count the number of lines in a text file. It has the following features: Supports Windows and Unix line endings. Handles long lines. Copes with notorious show-stoppers like Control Z and the Null Character . Works with Unicode as well as ANSI text files. Can count lines ...
by Sponge Belly
19 Apr 2013 10:22
Forum: DOS Batch Forum
Topic: can’t call func with "/?" as param
Replies: 2
Views: 1521

Re: can’t call func with "/?" as param

Hi Dave! Well, colour me embarrassed. That‘ll teach me to test my fruity hypotheses more thoroughly before opening my enormous gob. Anyways, I took on board what you said and came up with the following: @echo off & setlocal enableextensions (set file="%~1") echo(delayed expansion is of...