0

**Hi,

How would I write a Windows Command to delete all folders recurvsively with a specific wildcard name ({*}) under a specific path that is older than 10 days? I would like to run this on the command prompt and I also want to run it as a batch file.

set deletepath = "C:\test\"
set days = 10

Delete all subfolders under deletepath that is older than 10 days and begins with "{" and ends with "}" i.e. {*}**

Edited by pritaeas: Moved.

3
Contributors
5
Replies
24
Views
3 Years
Discussion Span
Last Post by Reverend Jim
0

I wrote this script a few years ago to do just that. You can modify it to restrict it to specific types of names. See attached.

Usage:

  delete_older_than #days [folder] [-s] [-l] 

  where 

    #days       number of days to keep 
    folder      name of folder containing files to delete 
                (default is current)
    -s          delete in sub-directories also (optional)
    -l          list files to delete withoout deleting them (optional)

Edited by Reverend Jim

0

Thanks for that. Is there anyway I could do this using MS-Dos commands that I can run occasionally or put into a batch file to run as a schedule job?

0

Is there anyway I could do this using MS-Dos commands

You can run it as a batch job. That's what scripts are for. vbs files are executed either by cscript.ece or wscript.exe. One is for command line (c) mode and the other is from windowed (w) mode. One difference is that under cscript.exe, output goes to the console window and under wscript.exe, output is to a MessageBox. You can set console as the default by

cscript //h:cscript //s

To run it automatically you can set up a task in the Task Scheduler.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.