I want to delete .txt extention files in my computer every 30 days using batch script...
files name are like:
filename_20082013.txt
filename_21082013.txt
filename_22082013.txt
filename_23082013.txt
I want to delete .txt extention files in my computer every 30 days using batch script...
files name are like:
filename_20082013.txt
filename_21082013.txt
filename_22082013.txt
filename_23082013.txt
suggestion for approx. 30 days, run the command on the first day of the month:
del *072013.txt
for this month and
del *082013.txt
for the next month.
The command also works in a batch script.
For Windows:
forfiles -p "C:\what\ever" -s -m *.* -d <number of days> -c "cmd /c del @path"
So:
forfiles -p "C:\your\path" -s -m *.txt -d -30 -c "cmd /c del @path"
Source: Batch file to delete files older than N days
This will delete files that are at least 30 days old (you can change it to any number)...now you need to schedule this task to run every 30 days:
You can use Windows Task Scheduler:
http://windows.microsoft.com/en-us/windows7/schedule-a-task
Or you can use StreamServe Task Scheduler:
http://streamshare.streamserve.com/Articles/Article/?articleId=424
You are looking for the "Task Scheduler" on Windows, or a cron job on Unix.