# Delete old files from a folder with some squence by batch



## Deepak54321 (May 10, 2016)

There is a folder in our app server where there are millions of files present. I have to delete the files based on a sequence. The sequence is weekly basis. Ex: firstly the list of files will be deleted those are created very first week. (The oldest week). Then again it will delete files created the newer week prior to that week. Likewise it should go.

And script will only keep files those are just 180 days older than the current date. Can you please help me with the batch code ?


Cheers !!!


----------



## lochlomonder (Jul 24, 2015)

I don't think you need to go down the route of creating a batch file, since an application such as Belvedere will handle file deletion based upon the criteria you laid out. I use it for cleaning up temporary files created by SQL Server, and it's basically a set & forget app.


----------



## Deepak54321 (May 10, 2016)

Ok, I will look for this tool and its implementation sooner. However can you please guide me what is the DOS command to know the oldest file created date inside a folder? As I said there are millions of files and when I am trying to sort the files manually it hangs and usually doesn't respond.

And also, can this tool (as you suggested) be configured as a scheduler ? 
many thanks in advance....


----------

