-1

I want to run a batch file that would delete files in a folder (and its sub folders) that are older then 30 days. I'm somewhat new to scripting so any help would be appreciated. The path to the folder is C:\Documents and Settings\user profile\Application Data\Program\Program\folder\company name

That folder has many random sub folders - I need the batch file to delete any file in those subfolders older then 30 days.

Is this something that can be done with a batch file or would I need a higher level script like vb scripting?

Endoro
  • 37,015
  • 8
  • 50
  • 63
  • http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days May be helpful. – Derek Story Jun 21 '13 at 18:04
  • 2
    possible duplicate of [Delete sub directories older than 30 days](http://stackoverflow.com/questions/3419091/delete-sub-directories-older-than-30-days), [Batch file to delete folders older than 10 days in Windows 7](http://stackoverflow.com/q/5497211/62576), [Batch file to delete files older than N days](http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days), and http://stackoverflow.com/q/324267/62576, just to name a few. Please do at least a basic search here before posting a new question to see if it's been asked and answered already. Thanks. – Ken White Jun 21 '13 at 18:16

1 Answers1

2

I did some copy and paste for you from here:

forfiles -p "C:\what\ever" -s -m *.* /D -30 /C "cmd /c del @path"

See forfile documentation for more details.

Community
  • 1
  • 1
Endoro
  • 37,015
  • 8
  • 50
  • 63
  • Instead of copy/pasting from a duplicate, flag it as a duplicate to close it. There's no need to add clutter here. – Ken White Jun 21 '13 at 19:38
  • Sorry. What exactly are you asking? This is a copy/paste from a question that could be used to close this as a duplicate. – Ken White Jun 21 '13 at 19:42
  • I could find no rule that prohibits me the copy & past. Are you a rule maker, member of a ruling clique here? Then I apologize to your majesty. – Endoro Jun 21 '13 at 19:46
  • Nope. I'm a user who has a vote to cast, and did so. There's no reason for getting rude or personal here. Please observe the rules regarding conduct toward others. Thank you. – Ken White Jun 21 '13 at 20:25
  • @KenWhite so please let me do my job and you do what you always do. your voting is not essential for me. the whole reputation system at SO is suspicious for me and not point of my enhanced interest. good luck so far. – Endoro Jun 21 '13 at 20:43