Discussion:
Can you have a date range in dir???
(too old to reply)
r***@gmail.com
2005-12-02 20:11:20 UTC
Permalink
Hi,
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory. Is this
possible?

Thanks
Ross
billious
2005-12-02 23:36:52 UTC
Permalink
Post by r***@gmail.com
Hi,
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory. Is this
possible?
Thanks
Ross
Yes.

The solution is OS-dependent. Ask in alt.msdos.batch for DOS/9x/ME or
alt.msdos.batch.nt for NT/2K/XP.

HTH

...Bill
foxidrive
2005-12-03 04:59:49 UTC
Permalink
Post by r***@gmail.com
Hi,
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory. Is this
possible?
Thanks
Ross
This post might help you. Newsgroups: alt.msdos.batch.nt is the right group
for XP posts.


From: Marco Maier Said <***@yahoo.it>
Subject: Re: batch file to del files older than 10 days (or something along
those lines)
Newsgroups: alt.msdos.batch.nt
Post by r***@gmail.com
I have some MSDE databases that I export to the file system on a nightly
basis, which in turn get backed up. These database exports start to take up
a sizeable amount of disk space. I would like to write a batch file that
automatically cleans them up every so often.
The exported database file names are based on the date, and constructed from
using a for statement on date/t. So an example file name would be
20040125DB.BAK.
I started expirementing with using dir | find to delete older files by
searching the "day", but started running into problems with single digit
days; ie "7" versus "07". I can perform a mathematical operiation on "7",
but not "07" without doing a lot of extra work. As an example, one batch I
wrote would delete files dated 1-9 on the 20th, delete files dated 10-20 on
the 28th, and delete files 21-31 on the 10th. A loop would be used to count
up from 1-9, and delete those files. But I ran into the "7" does not equal
"07" problem.
I was hoping someone could point me in the right direction as far as what
type of logic to use for a reliable and efficient script to accomplish this.
TIA
@echo off
findstr "^:" %~sf0 >_.vbs
cscript /b _.vbs
del _.vbs
:n=date()
:Set objFSO=CreateObject("Scripting.FileSystemObject")
:Set oFol=objFSO.GetFolder("c:\folder")
:Set Fils = oFol.Files
:For Each oFil in Fils
:o=Datediff("d",oFil.DateCreated,n)
:IF o>10 Then
:oFil.Delete
:End If
:Next
Dr John Stockton
2005-12-03 17:44:40 UTC
Permalink
JRS: In article <***@g49g2000cwa.googlegroups.com>
, dated Fri, 2 Dec 2005 12:11:20 local, seen in news:alt.msdos,
Post by r***@gmail.com
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory. Is this
possible?
HUNT * d b#-7 s p q e

will do all older than 7 days before the start of today.

NOWMINUS d7 vXXX

HUNT * d b%XXX% s p q e

will do all older than 7 days from now, ignoring Summer Time
transitions.

NOWMINUS, HUNT via sig line 3 below.

Both give SFNs. Both for any DOS-like OS, though the NOWMINUS line will
need modification for NT+ systems.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
Michael Bednarek
2005-12-04 02:15:52 UTC
Permalink
Post by r***@gmail.com
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory. Is this
possible?
Yes.

In 4DOS, it's trivial:

DIR /[d-7,1980-1-1]

4NT's (and 4DOS's) Date Ranges are documented at
<http://jpsoft.com/help/dateranges.htm>. 4DOS is free, 4NT is a
commercial product.

Other CLIs will probably require a more elaborate approach, or the use
of specialised utilities.
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Richard Bonner
2005-12-05 00:50:21 UTC
Permalink
Post by r***@gmail.com
I want to do a dir command that takes today's date and finds all the
folders that are older 7 days within the current directory.
Ross
*** Try XXCOPY, XSET, or 4DOS. All can handle date ranges.


Link to the above may be found in my "DOS Websites" Directory at:

http://www.chebucto.ca/~ak621/DOS/Websites.html



Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Loading...