UK Vintage Radio Repair and Restoration Discussion Forum

UK Vintage Radio Repair and Restoration Discussion Forum (https://www.vintage-radio.net/forum/index.php)
-   Vintage Computers (https://www.vintage-radio.net/forum/forumdisplay.php?f=16)
-   -   Word in file search utility, DOS (https://www.vintage-radio.net/forum/showthread.php?t=159173)

brenellic2000 24th Aug 2019 3:17 pm

Word in file search utility, DOS
 
Years ago (20+!) there was a useful DOS utility which allowed one to search the location of a particular word in any number of files on the PC, similar to /S command, but in a far greater internal depth.

Can anyone remember what it's called... and is it still around in DOS or W3.1?

GeoffB17 24th Aug 2019 6:10 pm

Re: Word in file search utility, DOS
 
I never saw such a thing, as you describe it, but I wrote a somewhat limited version for my own use, which I still use.

This works on text files ONLY, in the current directory. It's looking for all 'hits' of a specified word. I use it mainly for following variables, keywords, etc in modules of source code. The prog defaults to *.c, but other things can be added to the command line like *.prg or *.txt, *.htm etc.

The result is put to a file, comprising a header for each filename, then line number and (part) of the full text of the line.

It's a DOS prog, so it's 8.3 filenames only. This has been causing me some trouble recently, so maybe I should change it?

Any help?

Geoff

buggies 24th Aug 2019 7:33 pm

Re: Word in file search utility, DOS
 
Was it not simply "Find" ?

https://sites.google.com/site/pcdosr...mands#TOC-FIND
Pasted from the above site:-

___________________________________
FIND
External - DOS 2.0 and above

Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] [/S] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/S Search subdirectories also.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the prompt
or piped from another command.
/I is only available in DOS 5 and above.
/S is only available in PC DOS 7.
Also PC DOS 7 allows the use of wildcards in filenames while prior versions do not.
_______________________________________

Alistair D 24th Aug 2019 8:26 pm

Re: Word in file search utility, DOS
 
I used to use a program called Xtree Gold. Among the many file reading and manipulation functions was one that could search a selection of files for any chosen word or phrase.

Al

emeritus 24th Aug 2019 10:19 pm

Re: Word in file search utility, DOS
 
1 Attachment(s)
I paid 10p for a copy of "Field Guide to MS DOS 6.2" in a charity shop some years ago. A quick scan through it suggests that the commands FIND, FOR, and SORT, together with "piping" , can be used to search for text strings in a multiple files. Examples are given. Scans of the relevant pages attached.

No personal experience with using any of these commands. I have only used the book once, when the driver software for a LCD monitor for my WIN 98 PC managed to mess up the system so badly that I had to operate the PC in command mode, echoing the screen to a printer, to get it working again.

I loved Xtree Gold: we used to use it at GEC in the early 1990's. I still have a copy of the software on a floppy, but I couldn't get it to run on my PC.

arjoll 25th Aug 2019 4:33 am

Re: Word in file search utility, DOS
 
FIND will do that in a basic fashion.

Often I find it's useful to search for a particular word or phrase in a number of text files - specifically scripts for an accounting package I support, looking for things like a particular table or index name. FIND was always a little clunky for that, so I just wrote a little VB.NET program to do it - the guts of it is:

Code:

Dim di As New DirectoryInfo(strPath)
Dim files = From fi In di.EnumerateFiles(strType, SearchOption.AllDirectories)

For Each fi As FileInfo In files
  Dim findstring = IO.File.ReadAllText(fi.FullName).ToLower
  If findstring.Contains(strFind) Then
    Console.WriteLine("Found in {0}", fi.FullName)
  End If
Next

strFind is the lowercase text to find, strType is the file extension, and strPath is the directory to start from. Could be just as easily done in C#. Won't be much use in MSDOS though, but you could do similar things - I'd need to fire up DOSBox and see what the options are in QuickC.

cheerfulcharlie 25th Aug 2019 8:47 am

Re: Word in file search utility, DOS
 
Quote:

Originally Posted by Alistair D (Post 1170906)
I used to use a program called Xtree Gold. Among the many file reading and manipulation functions was one that could search a selection of files for any chosen word or phrase.

Al

A great program, made me understand PCs better in those early days.
They did one later called 'Xtree for Windows'
which was around in the Windows 3/95/era

brenellic2000 25th Aug 2019 9:15 am

Re: Word in file search utility, DOS
 
Thanks lads. I still use XTree on occasion but don't recall any 'find' facility... perhaps its only in Gold? I'll have a look and play with Find in DOS... meanwhile I'll continue searching for my old software catalogue!

brenellic2000 25th Aug 2019 3:42 pm

Re: Word in file search utility, DOS
 
Back agin! Been playing with the FIND command but while it works fine entering a single, known file name, it doesn't handle a batch of files, or wild cards... but it does the job, laboriously, for my immediate needs.

How does XTGold differ - does it search through a batch of files and sub-directories? (I have the earlier XTree Pro).

Barry

julie_m 25th Aug 2019 5:55 pm

Re: Word in file search utility, DOS
 
That sounds like the `grep` command in Unix. I'm fairly sure someone ported GNU grep (a popular Free and Open Source implementation of `grep`) to MS-DOS a long time ago.

emeritus 25th Aug 2019 6:57 pm

Re: Word in file search utility, DOS
 
Page 74 of the attachment I posted shows you how to do a wildcard search by combining FOR and FIND.

arjoll 25th Aug 2019 9:32 pm

Re: Word in file search utility, DOS
 
Quote:

Originally Posted by brenellic2000 (Post 1171064)
Back agin! Been playing with the FIND command but while it works fine entering a single, known file name, it doesn't handle a batch of files, or wild cards... but it does the job, laboriously, for my immediate needs.

Try something like:
Code:

for %f in (*.doc) do find /n /i "text" %f

brenellic2000 26th Aug 2019 9:40 am

Re: Word in file search utility, DOS
 
Thanks Arjoll, your "for %f in (*.doc)...." etc works fine, except for one problem... screen scrolling speed! There does not appear to be a 'by page' command (/p, |more etc or indeed ScrollLock on the keyboard) which works.

While it merrily flashes through all those files not containing the selected text, by the time it finds one which does, it is too late to hit 'Pause' - the file name having scrolled off the screen!

Is there a way of scrolling page by page, or slowing down the scroll speed, or going back a page??

Station X 26th Aug 2019 10:45 am

Re: Word in file search utility, DOS
 
From what I remember you enter " | more" (note leading space) at the end of the command line and then use the space bar to step to the next page.

G6Tanuki 26th Aug 2019 10:50 am

Re: Word in file search utility, DOS
 
What you could do is redirect the output to a file, then use your editor-of-choice to view the file.

If you issue the command then put "> C:\junkfile.txt" on the end, the output of your command will end up in c:\junkfile.txt for your later perusal.

See https://www.robvanderwoude.com/redirection.php

arjoll 26th Aug 2019 11:51 am

Re: Word in file search utility, DOS
 
Unfortunately piping through MORE as Graham suggested won't work here - it'll do the pipe on each individual iteration of FIND, not on the whole run.

G6Tanuki is close, but use >> file.txt instead - that will append each run to the file. With a single > you'll overwrite with each run and only ever get the results for the first file.

Trying something like:
More < for %f in...
May work as well, but I am not on my PC so can't check. I'll have a look in the morning NZ time.

brenellic2000 26th Aug 2019 3:43 pm

Re: Word in file search utility, DOS
 
Thanks,

While G6Tanuki's and Arjoll's improved save-to-file trick now makes it a manageable tool through EDLIN, I'm finding that it is very selective in reporting those files that contain the target word(s), correctly spelt, ignoring several files which I know for certain do! I'm mystified... but at any rate this fundamental unreliability makes the whole exercise rather pointless and I'm frankly better of using my instinct and the basic Type and Edit commands! Progress, eh?!

Anyway thanks very much for all your help - much appreciated as ever. Back to square one...

Barry

Oldcodger 26th Aug 2019 8:25 pm

Re: Word in file search utility, DOS
 
Quote:

Originally Posted by Alistair D (Post 1170906)
I used to use a program called Xtree Gold. Among the many file reading and manipulation functions was one that could search a selection of files for any chosen word or phrase.

Al

Xtree works ( to a limited extent on up to ,I think W7(,but there's a modern version that has no file length called Ztree.

kalee20 26th Aug 2019 9:36 pm

Re: Word in file search utility, DOS
 
Xtree gold is what I remember too. But it is limited in its ability to search within each file, as it has to be able to open and read each one to do so. I seem to remember it couldn't understand WordPerfect 5.1 files, for instance, so didn't find the search text if it was in one of these files.

arjoll 27th Aug 2019 1:04 am

Re: Word in file search utility, DOS
 
Quote:

Originally Posted by brenellic2000 (Post 1171301)
I'm finding that it is very selective in reporting those files that contain the target word(s), correctly spelt, ignoring several files which I know for certain do!

Quote:

Originally Posted by kalee20 (Post 1171374)
I seem to remember it couldn't understand WordPerfect 5.1 files, for instance, so didn't find the search text if it was in one of these files.

It sounds like a file format issue. FIND will just search for text within a file - if it's got control codes and other data in the middle of the word then it won't find it, and the same goes if the word you're looking for appears after an EOF character (^Z).


All times are GMT +1. The time now is 10:12 pm.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright ©2002 - 2023, Paul Stenning.