Re: find files which contains certain string

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Al Dunbar" <AlanDrub@xxxxxxxxxxxxxxxxxxx> wrote in message
news:uG12vSWpHHA.716@xxxxxxxxxxxxxxxxxxxxxxx

"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:eBFKdGSpHHA.4112@xxxxxxxxxxxxxxxxxxxxxxx
Jurgen Heijnen wrote:

Can someone help me creating a script which search for files which
contains
a certain string in the filename. the files are placed in 1 directory
and
there names differ,

I would hope that their names would differ - if not then they'd all be the
same file.

an example: 2383737.2006.01.csv of 4443335.2007.04.csv.
Now I need to search the directory for the filename which contains the
string
"2007.04", which stands for "april 2007".
Can somebody help or get me started

I have an example VBScript program that does this linked here:

http://www.rlmueller.net/FindFiles.htm

Or, at a command prompt:

dir {folder}\*.2007.04.csv

Or if you want to have a script do something with the file once found,
something like this in a batch script:

pushd {folder}
(set _ym=Enter year and month in yyyy.mm format: )
for %%F in (*.%_ym%.csv) do notepad %%F


/Al


Reading Al's answer I just realized I mis-understood the question. The
script I linked searches for files that have a specified string in the file
contents, not in the name of the file. The "dir" command seems the best
solution.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Formula to convert yyyy.mm.dd to yyyy.mm.dd.ddd? (Perhaps a tricky one?)
    ... >>script set in old days to putting date at the required yyyy.mm.dd. ... >>But we've been needing the days in the filename, ... >Both results will be text string as Excel formatting cannot return the two day ... For the standard format one, ...
    (microsoft.public.excel)
  • Re: find files which contains certain string
    ... Richard and All, ... a certain string in the filename. ... Now I need to search the directory for the filename which contains the ... Or if you want to have a script do something with the file once found, ...
    (microsoft.public.windows.server.scripting)
  • Re: find files which contains certain string
    ... a certain string in the filename. ... I would hope that their names would differ - if not then they'd all be the ... Now I need to search the directory for the filename which contains the ... something like this in a batch script: ...
    (microsoft.public.windows.server.scripting)
  • Re: remove words from mutiple files
    ... a filename, you need to make a small shell script that reads the whole ... directory and uses mv and sed together to rename the files that has ... the offending string it's name. ... More efficient in the script or just more efficient overall? ...
    (alt.linux)
  • Re: Finding if a file does not exist
    ... >> detail how you want the script to react to the list. ... > with this same string in the filename in a specified directory. ... For Each WPPFile in WPPFiles ...
    (microsoft.public.scripting.vbscript)