+ Post New Thread
Results 1 to 5 of 5
Scripts Thread, forfiles scripting problems in Coding and Web Development; Hi i am trying to write a script using forfiles to delete some files older than 5 days, list what ...
  1. #1

    Join Date
    Jan 2014
    Location
    southampton
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    forfiles scripting problems

    Hi i am trying to write a script using forfiles to delete some files older than 5 days, list what i have delted and output it to a file. but it dosent seem to work here is what i am using.

    forfiles /p c:\windows\system32\logfiles /s /d-5 /c "cmd /c echo @patH @filE & cmd /c del @file" > c:gill-delte.txt


    Im not any good at this so any help would be gratefully received.
    thanks in advance

  2. #2

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,621
    Thank Post
    648
    Thanked 1,620 Times in 1,450 Posts
    Rep Power
    421
    Take the echo out and just use the del statement and you'remissing a \ after c: for your log file.

    Ben

  3. #3

    Join Date
    Jan 2014
    Location
    southampton
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi thanks ill give that a go. thanks for your help, I though i needed the echo in to make it list content in the file...

  4. #4

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,621
    Thank Post
    648
    Thanked 1,620 Times in 1,450 Posts
    Rep Power
    421
    I'd expect that output to come from the del command itself and then you are piping it to a txt file.

    Not near a pc at the moment so can't test.

    Ben

  5. #5

    Join Date
    Jul 2014
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Hi,
    I want to delete all directories whose name starts with abc and are x days old. I am using forfiles as below but not getting output. Please help :
    forfiles /p location /m abc* /d -x /c "cmd /c IF @isdir == TRUE rd /Q @path"
    forfiles /p location /m abc.* /d -x /c "cmd /c IF @isdir == TRUE rd /Q @path"

SHARE:
+ Post New Thread

Similar Threads

  1. logon script problem
    By maark in forum Windows
    Replies: 4
    Last Post: 3rd September 2008, 04:00 PM
  2. Logoff Script problems and GPO
    By placky in forum Windows
    Replies: 3
    Last Post: 27th March 2008, 06:03 PM
  3. Scripting Problem - Printers
    By Behuck in forum Scripts
    Replies: 10
    Last Post: 8th April 2007, 01:38 PM
  4. Start Menu Script Problem
    By phillipmillward in forum Windows
    Replies: 4
    Last Post: 23rd November 2006, 08:50 AM
  5. Login script problem
    By SpuffMonkey in forum Windows
    Replies: 55
    Last Post: 4th February 2006, 09:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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