Hi guys!

could you help me on this please..

i need a code that moves the files in one folder to another folder(archive) depending on the date stamp on their filenames.

here are some sample filenames of my files(CSVFile_YYYYMM.csv):

CSVFile_201201.csv
CSVFile_201202.csv
CSVFile_201203.csv
CSVFile_201204.csv
CSVFile_201205.csv
CSVFile_201206.csv
CSVFile_201207.csv

i only need to retain the files that are in the past 2 months(CSVFile_201206.csv and CSVFile_201206.csv). Then the earlier months should be moved to the archived folder.

this code will be scheduled to run every monday. it will compare the "YYYYMM" of the files to the system date.

so for example if it will run today,

if CSVFile_YYYYMM.csv < ("201207") - 2
then move CSVFile_YYYYMM.csv to archive folder
else do not move

that would roughly be the condition.

I need your help guys! thank you very much!