DOS search with date in filename.

G

Guest

Not sure where to post this question so I'll add it in here and hope someone
can help me.

Trying to do a directory search by DOS where it would pull up a file with
today's date in the filename. Example would br yyyymmddFilename.txt, where
the yyyymmdd would be the current server date. Problem I'm running into is
that there are old files in the directory as well with previous dates in the
file name that I can't have being pulled up in the search. I must have only
the current dated file showing.

Any help would be greatly appreciated.

Thanks,
Mike
 
J

Jerold Schulman

Not sure where to post this question so I'll add it in here and hope someone
can help me.

Trying to do a directory search by DOS where it would pull up a file with
today's date in the filename. Example would br yyyymmddFilename.txt, where
the yyyymmdd would be the current server date. Problem I'm running into is
that there are old files in the directory as well with previous dates in the
file name that I can't have being pulled up in the search. I must have only
the current dated file showing.

Any help would be greatly appreciated.

Thanks,
Mike

See tip 8844 » Another way to return today's 4 digit year, 2 digit month, and 2 digit day, regardless of your date format
in the 'Tips & Tricks' at http://www.jsifaq.com

Assume you directory was c:\folder. Then:

@echo off
setlocal
call TDYMD YYYY MM DD
set YMD=%YYYY%%MM%%DD%
for /f "Tokens=*" %%a in ('dir /b /s /a c:\folder\%YMD%*.txt') do (
@echo %%a
)
endlocal

If the date may appear anywhere in the filename"
@echo off
setlocal
call TDYMD YYYY MM DD
set YMD=%YYYY%%MM%%DD%
for /f "Tokens=*" %%a in ('dir /b /s /a c:\folder\*%YMD%*.*') do (
@echo %%a
)
endlocal



Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
G

Guest

Looking at your tips listed the univdate.bat provides what I'm looking for.
However, bumping up the problem one more notch. Is there a way to get this
batch to run in the background of Windows 2000 server so that when a file
search is performed from a search bar %yy%%mm%%dd%.txt would be recongnized
as 20060419.txt?

The project I'm working on requires me to create a file dependency that it
watches prior to launching itself. However, due to there being serveral back
copies of previous dated files in the directory I'm needing to wildcard it so
Windows sees only the servers current date as part of the file name.

Thank again for an additional help,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top