Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry to ask this - must have been asked a zillion times before. Searched in here, but couldn't find an answer...

    Need to delete all files more than one week old from a specific folder. Want to do it from a BAT file, which I then intend to set with the AT scheduler.

    So all I need is something like this:

    IF "filedate" < today-7
    THEN DEL...

    TIA
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  2. #2
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='Henrik Ryberg' post='796604' date='06-Oct-2009 10:23'][/quote]
    I think our own BATcher posted on this recently, so wait for him...

    Meanwhile, in WinXP, I just tried a search putting in parameters as you see here. It correctly found 31 files in my "Word" folder, including three in a subfolder. Obviously, I didn't try deleting them.

    [attachment=85843:2009_10_06_104238.png]
    Attached Images Attached Images

  3. #3
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='Henrik Ryberg' post='796604' date='06-Oct-2009 15:23']Need to delete all files more than one week old from a specific folder. Want to do it from a BAT file, which I then intend to set with the AT scheduler.
    So all I need is something like this:
    IF "filedate" < today-7
    THEN DEL...[/quote]
    I wonder whether you have one of the Resource Kit Tools packages, which included FORFILES.EXE? If you have, then it's a one-liner!
    Otherwise, it is surprisingly complicated.
    It would help me if you told me what date format you get when typing DIR - in the UK it's dd/mm/yyyy e.g. 06/10/2009 for today.
    Let me know,
    and I'll have a go...
    BATcher

    Time prevents everything happening all at once...

  4. #4
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='BATcher' post='796612' date='06-Oct-2009 16:15']It would help me if you told me what date format you get when typing DIR - in the UK it's dd/mm/yyyy e.g. 06/10/2009 for today.[/quote]
    I've written it assuming UK date format - so let me know what your's is!
    BATcher

    Time prevents everything happening all at once...

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='BATcher' post='796653' date='06-Oct-2009 21:29']I've written it assuming UK date format - so let me know what your's is![/quote]

    Hi BATcher,

    Format is dd/mm/yyyy

    Currently I don't have the FORFILES.exe available, but I'll have a look around to see if I can get it.

    ...and the other solution would be?

    TIA
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  6. #6
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='Henrik Ryberg' post='796703' date='07-Oct-2009 08:42']...and the other solution would be? [/quote]
    The other solution would be the BATch file which I will upload this afternoon when I get home...!
    BATcher

    Time prevents everything happening all at once...

  7. #7
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='BATcher' post='796717' date='07-Oct-2009 11:06']The other solution would be the BATch file which I will upload this afternoon when I get home...![/quote]

    Looking forward to that - thanks a million
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  8. #8
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='Henrik Ryberg' post='796732' date='07-Oct-2009 12:03']Looking forward to that - thanks a million [/quote]
    Herewith, uploaded as DelOlder.txt...

    Beware that filenames containing an ampersand (&) cannot be processed and give a console error message.

    [attachment=85855elOlder.txt]
    Attached Files Attached Files
    BATcher

    Time prevents everything happening all at once...

  9. #9
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='BATcher' post='796778' date='07-Oct-2009 16:35']Herewith, uploaded as DelOlder.txt...

    Beware that filenames containing an ampersand (&) cannot be processed and give a console error message.

    [attachment=85855elOlder.txt][/quote]

    JC

    That was one huge amount of code for such a simple task

    I'll test it during next week.

    THX - appreciate your prompt responses.
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  10. #10
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='Henrik Ryberg' post='796898' date='08-Oct-2009 10:32']JC
    That was one huge amount of code for such a simple task [/quote]
    As I said, if you'd got FORFILES it is (almost!) a one-liner. It takes a lot more effort in BATch to do the job which that program was designed to do in 21K of (probably) Assembly language.
    BATcher

    Time prevents everything happening all at once...

  11. #11
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='BATcher' post='796908' date='08-Oct-2009 07:20']As I said, if you'd got FORFILES it is (almost!) a one-liner...[/quote]
    Does this look like a "safe" place to get it? This fella's a MS MVP, so I would think it's OK:

    Download Free Windows 2000 Resource Kit Tools

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    That website is OK, as far as I know. Daniel Petri is a well-known MVP.

  13. #13
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Denmark
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Bigaldoc' post='796913' date='08-Oct-2009 14:21']Does this look like a "safe" place to get it? This fella's a MS MVP, so I would think it's OK:

    Download Free Windows 2000 Resource Kit Tools[/quote]

    Hi Al,

    Any particular reason why you chose Win2000 and not eg. Win XP or Vista??
    - are there no resource kits there or is FORFILES not available for those?

    (Haven't had time to look further into this - so apologies if it sounds like a dumb question)

    TIA
    Bests,
    RD


    PS: Wish there were a knob on the TV to turn up the intelligence. There's a knob called "brightness," but that doesn't work

  14. #14
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='Henrik Ryberg' post='796917' date='08-Oct-2009 08:34']Any particular reason why you chose Win2000 and not eg. Win XP or Vista??[/quote]
    I don't know anything about the tools, so when I searched for it, i.e. FORFILES.EXE, the TechNet site came up at the top of the list showing the NT Resource Kit. In looking for a place to download it, I came upon this Petri fella's web site.

    For all I know there may not be a Resource Kit at the XP or Vista level. Someone else will have to comment on that.

  15. #15
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,420
    Thanks
    33
    Thanked 195 Times in 175 Posts
    [quote name='Bigaldoc' post='796922' date='08-Oct-2009 13:57']I don't know anything about the tools, so when I searched for it, i.e. FORFILES.EXE, the TechNet site came up at the top of the list showing the NT Resource Kit. In looking for a place to download it, I came upon this Petri fella's web site.

    For all I know there may not be a Resource Kit at the XP or Vista level. Someone else will have to comment on that.[/quote]
    There was an XP Resource Kit, a later one called Windows XP Support Tools, and Windows Server 2003 Resource Kit Tools...
    But the last time FORFILES.EXE appeared was in the Windows 2000 Resource Kit. (For NT it was in the original Resource Kit, Supplements 2, 3 and 4, and the Updates).
    (What is this Vista thing of which you speak?!)

    Daniel Petri's website is probably the single most useful website for Systems Administrators...
    BATcher

    Time prevents everything happening all at once...

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •