Delete old files by the last access date

Case Study, DOS - Windows Batch Files 21 Comments »

In my professionnal experience I have to manage many PC running with Windows XP. Those box are used for broadcasting some video flow and download lot of media files which aren’t managed by our software. Naturally, I had to find a solution for dynamically purge the lot of useless media files daily generated. As everyone working in system administration (I suppose…), I didn’t have lot of time for doing this job and our software developper couldn’t add the possibility to destroy old files (still due to lot of projects and short timeline…), so I decide to use the Windows schedule (AT) and doing a batch file.

As we had different software version - and for a maximum flexibility in case of any “kidding” evolution of this software - I take care to use arguments to my script. Here by I’ll describe all the process of this script that can be resume in five parts :

  1. Get and check our arguments
  2. Checking some dates (OS date format, maximum vailidity date)
  3. Parsing the directory to purge and get last access date of files
  4. Testing date and delete useless files
  5. Scheduling the batch file

Read the rest of this entry »

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in