Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can I use FORFILES to remove folders of files?  (Read 6708 times)

0 Members and 2 Guests are viewing this topic.

JTS

    Topic Starter


    Greenhorn

    Can I use FORFILES to remove folders of files?
    « on: June 15, 2009, 12:15:35 PM »
    I have a backup script that places the backup file into a current date folder.  I want to use a script to say truncate all folders that are earlier than 30 days from today's date

    I do have a FORFILES script but it appears it is for files only.  Is there a syntax to delete groups of folders based on the file system create date?

    Thanks

    ALAN_BR



      Hopeful

      Thanked: 5
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 7
      Re: Can I use FORFILES to remove folders of files?
      « Reply #1 on: June 15, 2009, 12:56:22 PM »
      "FORFILES script" is not a specific description., but Google found :-
      http://www.pcreview.co.uk/forums/thread-1466456.php

      That was posted by someone who wished to avoid the default action of deleting Folders as well as files - i.e. he did not like the default which you seem to require.

      Regards
      Alan

      JTS

        Topic Starter


        Greenhorn

        Re: Can I use FORFILES to remove folders of files?
        « Reply #2 on: June 15, 2009, 02:23:52 PM »
        Ok then what DOS command would I use to delete folders with files after x given days...


        gh0std0g74



          Apprentice

          Thanked: 37
          Re: Can I use FORFILES to remove folders of files?
          « Reply #3 on: June 15, 2009, 06:46:32 PM »
          if its possible, you can download findutils (see my sig), and use the find command (different from Windows own find command)
          Code: [Select]
          c:\test> find c:\test -type f -mtime +1 -delete

          the above delete files more than 1 day old. adjust as needed.

          JTS

            Topic Starter


            Greenhorn

            Re: Can I use FORFILES to remove folders of files?
            « Reply #4 on: August 21, 2009, 10:02:26 AM »
            BAM01 gave me this..

            Haven't tried this yet but it's supposed to move files to a second folder if they are 365 days old

            forfiles /p E:\path /m *.* /d -365 /c "cmd /c move @file e:\DELETE.FILES"




            Will try it out.

            billrich

            • Guest
            Re: Can I use FORFILES to remove folders of files?
            « Reply #5 on: August 23, 2009, 08:26:50 AM »

            C:\>rmdir /?
            Removes (deletes) a directory.

            RMDIR [/S] [/Q] [drive:]path
            RD [/S] [/Q] [drive:]path

                /S      Removes all directories and files in the specified directory
                        in addition to the directory itself.  Used to remove a directory
                        tree.

                /Q      Quiet mode, do not ask if ok to remove a directory tree with /S

            C:\>

            gh0std0g74



              Apprentice

              Thanked: 37
              Re: Can I use FORFILES to remove folders of files?
              « Reply #6 on: August 28, 2009, 06:27:29 AM »
              C:\>rmdir /?
              Removes (deletes) a directory.
              it just removes directory, but does not check for X days to delete. extra code is needed.