Search found 196 matches

by Sponge Belly
29 Jan 2014 16:34
Forum: DOS Batch Forum
Topic: slice.cmd
Replies: 9
Views: 3961

Re: slice.cmd

Hello Carlos! Slice was one of the first Batch programs I tried to write. I couldn’t output the lines verbatim so I asked for help on the alt.msdos.batch.nt newsgroup and a long, rambling thread unfolded. Your program was one of several submitted. Now that I have a better idea of what I’m doing, I c...
by Sponge Belly
29 Jan 2014 14:55
Forum: DOS Batch Forum
Topic: What's wrong with XP's for /f delimiter ?
Replies: 15
Views: 12809

Re: What's wrong with XP's for /f delimiter ?

Welcome to DosTips, Dave! Penpen’s answer is probably overkill for your requirements. Below is a little snippet that stores a tab in a variable along with an example of how to use it. Should work with any version of Windows from XP onwards. for /f "delims=" %%t in ('mshta ^"javascript...
by Sponge Belly
29 Jan 2014 08:25
Forum: DOS Batch Forum
Topic: Create nul and all ascii characters with only batch
Replies: 110
Views: 53328

Re: Create nul and all ascii characters with only batch

Hello All! Wow! What a fascinating thread. Allow me to tie up a few loose ends. I thought Penpen’s final version of CreateNul.cmd was definitive… and then I saw Carlos’s optimisation of my snippet. I’m going to be controversial and call it a draw! Squashman, I think this is the post on forfiles you ...
by Sponge Belly
28 Jan 2014 16:26
Forum: DOS Batch Forum
Topic: How to handle a comma in a filename with WMIC?
Replies: 32
Views: 13226

Re: How to handle a comma in a filename with WMIC?

Hi Again! I wondered why nobody replied to my posts. Then I realised Foxi was talking about square brackets in the filename and not the parentheses around the name clause of the wmic command. Anyways, here’s my mshta solution which is very much in vogue these days thanks to npocmaka and Einstein1969...
by Sponge Belly
27 Jan 2014 16:14
Forum: DOS Batch Forum
Topic: Create nul and all ascii characters with only batch
Replies: 110
Views: 53328

Re: createnul.cmd Create a file with the nul character

Hello All! Taking from DT: Another Way to Create a Linefeed Variable and SO: How to Write a Single Space to a Text File , I came up with this little snippet: @echo off & setlocal enableextensions (set lf=^ ) set nl=^^^%lf%%lf%^%lf%%lf% set "lfFile=%tmp%\lf.tmp" set "lfUTF=%tmp%\lf...
by Sponge Belly
21 Jan 2014 17:23
Forum: DOS Batch Forum
Topic: How to handle a comma in a filename with WMIC?
Replies: 32
Views: 13226

Re: How to handle a comma in a filename with WMIC?

Hi Endoro! Great question. Turns out the equals sign after name must be caret-escaped: X:\> set "fn=%cd%\tom, dick & harry.txt" X:\> type nul >"%fn%" X:\> for /f "skip=1" %f in (' More? wmic datafile where (name^="%fn:\=\\%"^) get lastmodified More? ') do ...
by Sponge Belly
21 Jan 2014 14:01
Forum: DOS Batch Forum
Topic: How to handle a comma in a filename with WMIC?
Replies: 32
Views: 13226

Re: How to handle a comma in a filename with WMIC?

Hello All! I combined AiroNG’s parentheses and Penpen’s backslash-escape techniques and ended up with something like this: X:\> set "fn=%cd%\tom, dick & harry.txt" X:\> type nul >"%fn%" X:\> wmic datafile where (name="%fn:\=\\%") get lastmodified LastModified 201401...
by Sponge Belly
20 Jan 2014 18:42
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 10338

Re: two findstr questions

Hi Again! Thanks to everyone who answered. And apologies for not replying sooner. I was having a little break… Anyways, I plundered some code from one of the links Squashman suggested and came up with this snippet that finds the longest line in a file: @echo off & setlocal enableextensions enabl...
by Sponge Belly
05 Jan 2014 16:36
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 10338

Re: two findstr questions

Hi Foxi, In SO: Undocumented Features and Linitations of FindStr , Dave Benham wrote: Piped data and Redirected input is limited to 8191 bytes per line. This limit is a “feature” of FINDSTR. It is not inherent to pipes or redirection. FINDSTR using redirected stdin or piped input will never match an...
by Sponge Belly
04 Jan 2014 08:49
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 10338

two findstr questions

Happy 2014 to All! I thought I could use findstr to scan a file for lines that had more than 8191 characters. I came up with: findstr "^" longlines.txt | findstr "^" >nul FINDSTR: Line 3 is too long. FINDSTR: Line 5 is too long. Are there different language versions of findstr? I...
by Sponge Belly
25 Dec 2013 06:37
Forum: DOS Batch Forum
Topic: bowling, anyone?
Replies: 7
Views: 3806

Re: bowling, anyone?

Happy Christmas All! Just a quick note to say the link in the OP still works. Also, I’ve moved from XP to Win 7. The game crashes just as frequently as before, only now it doesn’t bring the whole machine down with it. Btw, press Ctrl-X to score a strike every time and Ctrl-D to hit the deer. Have fu...
by Sponge Belly
19 Dec 2013 13:53
Forum: DOS Batch Forum
Topic: DIR command not Refreshed
Replies: 5
Views: 1874

Re: DIR command not Refreshed

Hi Yossi, :-)

Try the following:

Code: Select all

type dynamic-file.log >nul
dir dynamic-file.log


A tip I picked up from ss64.com’s page on the type command.

Hope this helps!

- SB
by Sponge Belly
30 Nov 2013 14:13
Forum: DOS Batch Forum
Topic: Processing text files that have unlimited size lines!
Replies: 24
Views: 7532

Re: Processing text files that have unlimited size lines!

Sorry I’m late! Here’s some beta code that reads in a file containing a single long line (NULs and newlines not supported). It splits it up and spits it back out in 4095-character chunks by misusing pause and find: @echo off & setlocal enableextensions enabledelayedexpansion if "%~1" n...
by Sponge Belly
26 Nov 2013 04:16
Forum: DOS Batch Forum
Topic: question about the "find" command
Replies: 3
Views: 1282

Re: question about the "find" command

Hi AiroNG, :-)

The findstr command will do what you want:

Code: Select all

findstr /l "text" "*.txt"


It will output only the filenames that contain the matching text. Read findstr’s help for more info. There are many switches to be mastered.

Good luck! ;-)

- SB
by Sponge Belly
20 Nov 2013 10:24
Forum: DOS Batch Forum
Topic: truncate files - a (pure?) batch solution
Replies: 3
Views: 4590

Re: truncate files - a (pure?) batch solution

Dear DosTippers, While participating in a long, meandering thread about something else entirely, I prepended a BOM to a plain ASCII file and redirected it to a new file as below: cmd /d /u /c type bomfile.txt > newfile.txt To my surprise, the BOM was missing from the new file and the new file was 1 ...