Computing.Net > Forums > Disk Operating System > simple search batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

simple search batch file

Reply to Message Icon

Name: mikedosboy
Date: December 16, 2005 at 15:32:02 Pacific
OS: windows 3.1
CPU/Ram: tandy 33mhz 4 mb ram
Comment:

Hi...I'm wondering if anyone knows how to search for specific filenames, then list all other files that don't match that format. the format is

??_??_??.*

Any other file that doesn't match this should be listed, then printed.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: mikedosboy
Date: December 16, 2005 at 16:46:31 Pacific
Reply:

To be clearer, the "Find" command is defined as follows:

"The find command searches files for the string or text that you specify"

I need to find everything else that the find command does NOT specify.

Is there a way oh enlightened ones?


0

Response Number 2
Name: Mechanix2Go
Date: December 16, 2005 at 19:50:04 Pacific
Reply:

Not clear what you want to do.

but FIND is for finding 'strings' in text files, NOT for finding files.

You can:

dir ??_??_??.*

Try to restate what you want to do.


If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: Mechanix2Go
Date: December 16, 2005 at 23:11:02 Pacific
Reply:

Also, it will depend on the version of DOS.

The ability to do a dir/s was added in DOS 5.0 or 6.x, so if your DOS is earlier, you'll have different issues vis-a-vis finding files not in the current directory.

In brief, to get two lists, one with the file names which contain a _ and another list of files which don't:

dir |find "_" > with_.lst
dir |find /v "_" > no_.lst

Getting down to a list with the _ in particular positions will take much more doing.

Let us know.



If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: wizard-fred
Date: December 17, 2005 at 04:41:45 Pacific
Reply:

If you can accept a two pass solution, first make a list of all file names, then delete those that match your search pattern. I believe a utility like grep will delete the unwanted names from the list.


0

Response Number 5
Name: rhi
Date: December 18, 2005 at 01:11:19 Pacific
Reply:

wizard fred's solution is simpler and better.

Check your site's google Page Rank here


0

Related Posts

See More



Response Number 6
Name: dtech10
Date: December 18, 2005 at 14:06:43 Pacific
Reply:

Hi Michdosboy

This help.
----------------------
@echo off
attrib +h ??_??_??.*
dir /b /a-d-h > prn
attrib -h ??_??_??.*


0

Response Number 7
Name: mikedosboy
Date: December 19, 2005 at 12:55:33 Pacific
Reply:

Wow, dtech10's solution was perfecto. You are truly a dynamic genious. Thanks alot!

One question, for some reason, the >prn part of the batch file was actually crashing the execution of the batch file. Any idea why?

But, the gist of the code you gave me works beautifully.

Thanks so much.


0

Response Number 8
Name: mikedosboy
Date: December 19, 2005 at 13:00:43 Pacific
Reply:

Actually, that code works perfectly except when I add a "/s" switch to the "dir" command, it still lists files with the "??_??_??.*" format. It only excludes the files on the current directory, but I need to search thru all subdirectories.

Anyone know why?


0

Response Number 9
Name: mikedosboy
Date: December 19, 2005 at 13:03:35 Pacific
Reply:

Nevermind. I figured it out. Here's my code now:

attrib +h ??_??_??.* /s
dir /s /b /a-h-d
attrib -h ??_??_??.* /s


Thanks for all your help guys.

Anyone have any hints on printing this list?

Thanks.


0

Response Number 10
Name: dtech10
Date: December 20, 2005 at 15:03:03 Pacific
Reply:

Hi Mike

This work ok.

attrib +h ??_??_??.* /s
dir /s /b /a-h-d > File.txt
attrib -h ??_??_??.* /s
print File.txt



0

Response Number 11
Name: mikedosboy
Date: December 20, 2005 at 18:38:12 Pacific
Reply:

Oh, I'm so dumb. Thanks alot, it works like magic now. Thank you!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: simple search batch file

Simple DOS batch file www.computing.net/answers/dos/simple-dos-batch-file/7596.html

Simple copy batch file, please help www.computing.net/answers/dos/simple-copy-batch-file-please-help/11154.html

Batch file - search for file www.computing.net/answers/dos/batch-file-search-for-file/12094.html